Document assembly system

ABSTRACT

A document assembly or document automation system includes an assembler for generating an instance document on the basis of a source document and one or more logic source documents referenced by the source document. The source document and logic source documents are XML documents including at least one XML processing instruction. The source document and logic source documents are valid with respect to XML schema. The system generates an instance document in HTML, PDF or RTF format by resolving variables in the source document and/or logic sources using one or more data sources. This may involve performing one or more interview rounds with a user of the system, access to a database, and/or evaluation of a function defined in one of the documents. The system includes an editor for creating and maintaining source documents and logic source documents whilst maintaining their validity with respect to the appropriate XML schema.

This is a non-provisional application claiming the benefit ofInternational application number PCT/AU03/00253 filed Feb. 28, 2003

FIELD OF THE INVENTION

The present invention relates to document assembly or documentautomation, and in particular to a document assembly system, and methodsexecuted by components of the system.

BACKGROUND

Document assembly refers to the generation of an instance document fromone or more source documents. In general, a source document is a generictemplate document, and additional information specific to the relevantcircumstances is required to generate an instance document from one ormore source documents. This additional information can originate from auser and/or some other data source. Document assembly software has beendeveloped for generating documents that typically contain large amountsof common text or data with a smaller amount of varying detail text ordata. Document assembly software is useful because, where a suitablesource document exists, it enables instance documents to be producedmore efficiently than may otherwise be the case using a standard wordprocessor. A form letter is perhaps the simplest and most familiarexample of a source document, and can be used to generate instanceletters for a number of recipients. An instance letter is typicallygenerated from a single source document and addressee information, suchas the addressee's first and last names, title, and address. Morecomplex instance documents, such as legal or financial documents, can begenerated from one or more source documents, based on informationspecific to the parties involved and the circumstances of theirrelationships.

A source document is represented in a document assembly system in somedata format. Common data formats (only some of which are commonly usedfor source documents for a document assembly system) include plain text,Microsoft's proprietary Microsoft Word “doc” format, the rich textformat (RTF), portable document format (PDF), and hypertext markuplanguage (HTML). A data format which is now being used for a widevariety of applications is extensible markup language (XML), asdescribed at http://www.w3.org/XML. An XML document combines the text ofa document with tags that markup that text into logical elements. As adata format for storing documents generally, XML has a number ofadvantages over other data formats. In particular, XML can be used tomarkup text in a way that tags it with its meaning or purpose, andapplications can manipulate the text on the basis of these tags. Toolsfor parsing and manipulating XML data are available from a variety ofvendors.

XML allows a document grammar to be defined which an XML document mustmatch if it is to be said to be valid with respect to that grammar. If adocument is valid, then systems that can handle documents matching thatgrammar can manipulate those documents taking advantage of the grammar.Such a grammar is often contained within a “document type definition”(DTD) or “XML schema”. There are many different grammars for XMLdocuments that are designed to meet specific needs. For example, theDocBook document type definition, documented athttp://www.oasis-open.org/docbook/xml/, was designed to meet verygeneral documentation requirements.

A document assembly system preferably performs a number of basicfunctions. First, it determines, on the basis of data provided to it,which parts of a source document to include in or exclude from aresulting instance document. For example, a paragraph, sentence orphrase might only be included in a legal contract if there is aguarantor. Second, the system can also include in the instance documenttext which is not present in the source document. For example, a date,an address, or where a user of the system enters a yearly rental, theamount calculated to be payable per calendar month. In order to be ableto provide these two basic functions, a document assembly system stores(i) information as to which parts of the source document may be includedor excluded from the instance document, and (ii) information as to thelocations in the document in which additional text may be inserted.

It is also desirable to be able to repeat a passage of text a specifiednumber of times, but with different data inserted at certain pointswithin the passage in each repetition. This requires the ability toidentify the passage to be repeated, the number of times to repeat it,and the data to be inserted into each repetition.

Existing document assembly products that work with source documentswhich are not XML based often encode the information described abovedirectly in the source document. This is possible with XML sourcedocuments as well. The information could be stored as additionalelements or attributes in the XML document itself. However, a seriousdifficulty with this approach is that the document will not be validunless the grammar is altered to allow the inclusion of thatinformation.

In an alternative approach, taught in U.S. Pat. No. 6,006,242 (Poole, etal. “Apparatus and method for dynamically creating a document”), entityreferences are embedded in a document instance, and a dedicated entityresolver is used during the document assembly process to replace theentity references with text particular to the instance document. Oneproblem with this approach is that the source document will not validateagainst the original grammar unless the validating parser being useduses that dedicated entity resolver.

Because in each of these approaches the document no longer validatesagainst the original grammar using a validating XML parser, the abilityto manipulate the document with 3^(rd) party XML-aware applications issignificantly curtailed.

It is desired to provide a document assembly method and system, a methodfor generating a source document for a document assembly system, asource document for a document assembly system, a logic source for adocument assembly system, and a grammar for a logic source for adocument assembly system that ameliorate one or more of the abovedifficulties, or at least provide a useful alternative.

SUMMARY OF THE INVENTION

In accordance with the present invention there is provided a documentgeneration system, including:

-   -   (i) a generation component for generating an XML source document        by associating an initial XML document with one or more logic        sources, said initial XML document and said XML source document        both being valid with respect to the same predetermined DTD or        schema; and    -   (ii) an insertion component for inserting in said XML source        document one or more assembly instructions for determining        content of an instance document.

The present invention also provides a method for generating an XMLsource document for a document assembly system, including:

-   -   (i) generating said XML source document by associating an        initial XML document with one or more logic sources, said        initial XML document and said XML source document both being        valid with respect to the same predetermined DTD or schema; and    -   (ii) inserting in said XML source document one or more assembly        instructions for determining content of an instance document.

The present invention also provides a document assembly method,including:

-   -   accessing an XML source document including one or more assembly        instructions and one or more logic sources associated with said        XML source document; and    -   generating an instance document on the basis of said XML source        document and said logic sources, wherein said XML source        document is valid with respect to a predetermined DTD or schema.

The present invention also provides a document assembly system,including a processing engine for generating an instance document fromat least one XML source document and one or more logic sourcesassociated with said at least one XML source document, wherein said atleast one XML source document is valid with respect to a predeterminedDTD or schema.

The present invention also provides a document assembly system,including an editor for generating an XML source document by associatingan initial XML document with logic for use in generating an instancedocument from said XML source document, said initial XML document andsaid XML source document being valid with respect to the samepredetermined DTD or schema.

The present invention also provides an XML source document for adocument assembly system, said XML source document including one or moreassembly instructions for determining content of an instance document,said XML source document being valid with respect to a predetermined DTDor schema.

The present invention also provides a logic source for a documentassembly system, said logic source including one or more logic elementsfor determining content of an instance document from an XML sourcedocument associated with said logic source, said XML source documentbeing valid with respect to a predetermined DTD or schema.

BRIEF DESCRIPTION OF THE DRAWINGS

Preferred embodiments of the present invention are hereinafterdescribed, by way of example only, with reference to the accompanyingdrawings, wherein:

FIG. 1 is a block diagram of a preferred embodiment of a documentassembly system connected to a remote computer system via acommunications network;

FIG. 2 is a block diagram of document assembly modules, standardprocessing modules, and document assembly data files of the system;

FIG. 3 is a block diagram showing components of an editor of the system;

FIG. 4 is a block diagram of a processing engine of the system;

FIG. 5 is a flow diagram of a document assembly process used by thesystem;

FIG. 6 is a screenshot of an interview screen displayed by a web browserduring the document assembly process;

FIG. 7 is a screenshot of a web browser displaying an instance documentin HTML format generated by the system;

FIG. 8 is a schematic diagram showing the relationships between a basesource document and reusable document components referenced by the basesource document;

FIGS. 9 and 10 are schematic diagrams illustrating party mappingperformed by the system;

FIG. 11 is a screenshot of a multiple choice question displayed by a webbrowser during the document assembly process;

FIG. 12 is a schematic diagram illustrating the development of documentassembly files using an editor of the document assembly system; and

FIGS. 13 to 15 are screenshots of the editor during development ofdocument assembly files.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT

In this specification, a reference to a document includes a reference toentries in a file system, database or other library, which can be takentogether to represent the document. A reference to a document includes areference to a collection of documents.

As shown in FIG. 1, a document assembly system includes a server 102having a number of modules 106 to 112. The document assembly system canbe remotely accessed by a user of a computer system 114 via acommunications network 116, such as a local area network or a wide areanetwork such as the Internet. The modules 106 to 112 of the documentassembly system include standard processing modules 106, documentassembly modules 108, and document assembly data files 110. The systemalso includes an editor 112 for creating and editing the data files 110.As shown in FIG. 2, the standard processing modules 106 include a webserver (such as Apache™) 205, an HTTPD servlet container 216, an XMLparser 206, and an XSLT engine 207.

The document assembly modules 108 include a Java controller servlet 218,a processing engine 202 and a rendering engine 204. The Java controllerservlet 218 was created using the Java Development Kit available fromSun Microsystems®, and provides an interface between the other documentassembly modules and the servlet container 216. A user of the computersystem 114 can access the document assembly system using a web browserapplication executing on the computer 114. HTTP requests generated bythe browser are sent over the network 116 and are received by the HTTPDservlet container 216. Access to the document assembly modules 108 isprovided via the Java Servlet 218, which in turn invokes the processingengine 202 to generate an instance document on the basis of the documentassembly data files 110. The instance document is rendered by therendering engine 204 to generate a rendered document which is sent tothe user's web browser via the Java controller Servlet 218.

The data files 110 include source documents 208, logic sources 210,document grammars 212, and logic grammars 214. The data files 110 mayalso include stored response data 215. In the described embodiment, theserver 102 is a standard computer server such as a Sun Fire® 15K serverfrom Sun Microsystems® and executing a Solaris® operating system, andthe processing modules 106, 108, and 112 of the document assembly systemare implemented as software modules stored on hard disk storage 104 ofthe server 102. The data sources 110 are data files also stored on thehard disk storage 104. However, it will be apparent that the modules ofthe document assembly system can alternatively be distributed over avariety of locations, and that at least part of the modules 106, 108,and 112 can be alternatively implemented as dedicated hardwarecomponents such as application-specific integrated circuits (ASICs).

The document assembly system generates instance documents from one ormore generic source documents 208 on the basis of information providedby one or more data sources. The data source is typically a user of thesystem, but other data sources can be used in addition to, or insteadof, a user. In the case when a user is a data source, this informationis provided in the form of responses to questions generated by thesystem on the basis of information contained in logic sources 210. Thedocument assembly system uses XML as the data format for representingsource documents 208 and logic sources 210. In addition to elements usedfor structuring data, XML defines a comment and a processing instruction(PI). A processing instruction is not part of a document's usualcharacter data, but is instead passed through to an application. Thus aprocessing instruction can be included in a document without affectingits validity. The form of a PI can be represented as follows:

-   -   PI::=‘<?’ PITarget (S (Char*−(Char* ‘?>’ Char*)))?‘?>’

The information in the processing instruction is not itself checked by aparser at all (apart from ensuring it begins with a string PITarget,used to identify the target application for the PI). Moreover,processing instructions can be placed anywhere in an XML document. Thedocument assembly system uses PIs to separate logic used to generate aninstance document from the source document itself. A source document 208includes references to external logic sources 210 that are required toresolve the logic contained in the source document 208 itself.

A source document 208 is a structured XML document, usually includingone or more processing instructions, as described above. Some of theseprocessing instructions include logic components that are used todetermine the content of instance documents generated from the sourcedocument 208. The logic in a source document 208 is resolved using logicfrom one or more external logic sources 210. A logic source required bya source document 208 is identified by a reference (in the form of auniversal resource indicator (URI)) in a processing instruction. Thelogic sources 210 are themselves structured XML documents that definequestions, conditions, and reusable text objects. The processing engine202 uses the XML parser 206 to read source documents 208 and logicsources 210. A logic source 210 can include one or more references toother logic source documents 210. The source documents 208 are describedby document grammars 212, against which the source documents 208 can bevalidated. Similarly, the logic sources 210 can be validated againstlogic grammars 214.

The processing engine 202 resolves logic associated with an XML sourcedocument 208. When a user of the system is used as a data source, thelogic is resolved by performing one or more question and answerinterview rounds that determine which components and text from thesource documents 208, referenced logic sources 210 and user responsesare included in the resulting instance document.

A logic source includes XML elements that are used to determine valuesfor variables required by a source document or other logic sourcereferring to that logic source. These variable values are usuallydetermined from responses provided by a user of the system in responseto questions defined in one or more logic sources 210 referenced by thesource document, either directly or indirectly via a chain ofreferences. The process of displaying questions to the user andreceiving responses to those questions is referred to as an interview,and the data defining these questions and possible responses to them isreferred to as interview data. A given set of responses to a set ofquestions can be stored as stored response data 215 on the hard disk 104of the document assembly system. The user's responses are used to assignvalues to variables, such as setting Boolean variables to a value oftrue or false for determining whether an associated portion of text isto be included in a generated instance document. These variables valuesare referred to as assembly data.

During the course of resolving all the logic necessary for the renderingengine 204 to be able to render an instance document, the processingengine 202 may modify a document object model (DOM) representation ofthe source XML document 208, for example, by physically including XMLfragments to which the source XML document 208 refers.

After the processing engine 202 has resolved all the logic necessary forthe rendering engine 204 to be able to render the instance document in aform suitable for viewing by humans, the rendering engine 204 transformsthe source XML document (as modified by the processing engine 202),omitting elements subject to an inclusion condition found to be false,and including responses to questions where appropriate into the desiredinstance format. Initially, the rendering engine 204 generates an HTMLrendering of the instance document that includes controls for furtherprocessing of the document. Once an instance document has beenfinalised, the rendering engine 204 is used to generate a finalrendering of the instance document, as described below.

It will be apparent that in order to generate an instance document inthe format requested by the user (other than XML), it is not necessaryto first generate an instance document in XML that is valid with respectto the same grammar as the source XML document. For desired instanceformats other than XML (XML that is valid against the same grammar asthe source XML document), the source XML document (as modified by theprocessing engine 202) is transformed by the rendering engine 204 intothe desired instance format via several intermediate XML formats. Duringthe course of those transformations, the processing instructions arereplaced as appropriate with the information obtained during theinterview process.

In an alternative embodiment, the processing engine 202 generates aninstance XML document (using the same grammar as the source document ora similar one) for the rendering engine 204. In yet a furtheralternative embodiment, the generation of that instance XML document isan early step performed by the rendering engine 204 in the course ofgenerating the instance document in the format desired by the user.

Source documents 208 and logic sources 210 are created and maintainedusing the editor 112, as shown in FIG. 3. In the described embodiment,the editor 112 is shown as being stored locally on the server 102.However, it will be apparent that the editor 112 can alternatively bestored and executed on a remotely located computer system and used toedit document assembly files at that location, providing that theresulting files are accessible by the parser 206 and processing engine202 of the system. The editor 112 includes a user interface module 302,an XML editor module 304, a validation module 306, and a logic module308. The user interface 302 and XML editor 304 modules allow a user ofthe document assembly system to add, modify, or delete XML elements,attributes, comments, processing instructions, and text. The XML editormodule 304 provides standard XML editor functions plus the ability toadd and manipulate condition references, reusable text, user text,notes, and meta-information processing instructions around and withindocument components. If a processing instruction having some otherpurpose is added to the system, the XML editor module 304 is altered toadd and manipulate that sort of processing instruction as well.

The validation module 306 provides standard XML document validation, aswell as logic source validation, and validation of interactions betweensource XML documents 208 and logic sources 210. The logic module 308allows the user to define and manipulate questions, conditions andreusable text. It also allows the user to define parameter values thatare used to determine default answer to questions, as described below.The editor 112 allows a user to define and manipulate logic within thelogic sources 210, manipulate XML documents 208, and add logicreferences to a logic source 210 within an XML document 208. The editor112 parses XML elements using the XML parser 206. The editor 112 usesthe document grammars 212 and logic grammars 214 to determine whichelements can be added and deleted, and how they can be manipulated.Grammars are also used as a basis for determining what types of logiccan be added. For example, reusable text can only be added to elementsthat are allowed to contain text.

The processing engine 202 is coded in the object-oriented programminglanguage Java. The Java language specification defines the notion of apackage. As shown in FIG. 4, the processing engine 202 includes anEvaluator 402, an evaluable node package 404, a parties package 406, aninterview items package 408, and a logic sources package 410.

The evaluable node package 404 contains classes that represent aCondition and the various elements that are allowed within a Condition(e.g., And, Or, Not, Test and UseCondition). Each of these implement aninterface called EvaluableNode. That interface defines an evaluatemethod that can be invoked in order to determine whether the value ofthe evaluable node is true or false.

The parties package 406 contains a class that represents a Party “known”to the source document, a Parties class that represents all knownparties, and a class that represents a PartyDetail.

The interview items package 408 contains classes that represent thequestions which the evaluator module 402 has encountered, and anyresponses that may have been provided or, for non-“key” questions,generated automatically. These include MultipleChoiceQuestions referredto in a Test, UserTextQuestions, and interview items encountered in anArrayRowIterator.

The logic sources package 410 represents each logic source used directlyor indirectly by the source document, and their contents, so that when areference to a piece of logic is encountered, the logic can be retrievedefficiently.

The evaluator module 402 is the collection of classes that orchestratethe evaluation of the source document. It controls the evaluationprocessing, represents the state of the evaluation and calls thepackages described above as necessary.

The rendering engine 204 includes an XSLT module which is used fortransforming XML documents, a collection of XSL transformations, andseveral Xalan extensions which are used to manipulate objects referencedby the processing engine 202's evaluator module. XSLT and Xalan areavailable and documented at http://xml.apache.org/xalan-j/.

The processing engine 202 begins processing an input XML document 208when its invocation API is called by an invoking process 412. In thepreferred embodiment, the invoking process 412 is the Java controllerservlet 218 which invokes the processing engine 202 in response to arequest from the user's web browser passed to it from the HTTPD servletcontainer 216. However, the processing engine 202 can alternativelyrespond to requests from other applications or a Web service.

The invoking process 412 asks the evaluator module 402 to evaluate thesource document. While there are interview items for which the evaluatormodule 402 currently needs a response, the evaluator module 402 returnsthose interview items to the invoking process 412. It is theresponsibility of the invoking process 412 to obtain a response for eachof those interview items via some InterviewItem Resolution Mechanism414. In the preferred embodiment, the Interview Item ResolutionMechanism usually renders those interview items as inputs on an HTMLform sent to the user's web browser, although in some cases it resolvesthe interview item in some other way, for example via a query to adatabase, or by invoking a web service. In such cases, an Other Sourcesmodule 416 provides an interface to data sources such as databases, filesystems, web services, directory services, and so on. The invokingprocess 412 then passes the interview items, together with theirresponses, back to the evaluator module 402.

FIG. 5 shows the steps followed when creating an instance document froma source XML document using a web browser executing on the user'scomputer 114. At step 502, the user selects a suitable source XMLdocument from the repository of documents 208 stored on the documentassembly system. At step 504, the user answers setup questions for oneor more subsequent question or interview rounds. This includesspecifying whether the user wants to be asked all questions duringsubsequent interviews, or just the “key” questions, in which case thesystem executes a scoring procedure, discussed below, to answer thenon-“key” questions with the response having the highest score. If thereis more than one Party used in the source XML document, then the usercan specify which of the parties the user wishes to favour. This is usedduring subsequent interview rounds to select default responses that suitthe selected party, and is also used by the scoring procedure that thesystem uses to answer questions itself. At step 506, successive roundsof interview questions are presented to the user until all the questionsthat need to be answered in order for the system to generate an instancedocument have been answered. The system uses multiple rounds ofinterviews in order to limit the number of questions asked to thosenecessary for a particular situation. In some documents, e.g., legaldocuments, it may not be possible to determine whether a particularquestion needs to be asked until answers have been provided for severalother questions. The system therefore asks the necessary questions in aseries of interview rounds, with the questions for a particularinterview round determined from answers provided in one or more previousrounds.

As described above, the interview rounds are used to determine valuesfor variables used by the source document and/or referenced logicsources, and these variables determine content of the resulting instancedocument. In the general case, where some or all variables are resolvedfrom data sources other than a user, the variables are resolved at step506, as described below, until the system is able to generate aninstance document.

Variables that can be resolved without user input are resolved by theprocessing engine 202 from other data sources. The processing engine 202provides the questions to which it requires responses to the Javacontroller servlet 218. It is the responsibility of that servlet 218 toreturn the responses to the processing engine 202. Where the questionsare put to a user via their web browser, the controller servlet 218 canput all the questions to the user in a single HTML form, or it can putthe questions to the user one at a time, or it can group them by topic,asking the questions in a single topic in a given form.

For example, FIG. 6 is a screenshot of a web browser display during aninterview round for generating an instance document that is a letter ofemployment for a prospective employee. The display includes twoquestions for the user. The first is related to the employee's expectedwork hours. A shaded area 602 displays a question presented to the userin a previous interview round, together with the user's response. Thequestion asked was whether the employer permits flexible working hoursin relation to the employee. Because the answer previously provided wasin the affirmative, subsequent questions 604 are displayed to the userin order to determine the nature of this flexibility. In this example,the questions are to determine the employer's normal office hours andthe core working hours in which the employee is expected to be present.The user enters the appropriate answers in text boxes 606 displayedunder each question 604.

In response to the user selecting a button 608 labelled “next”, theprocessing engine 202 determines, at step 506, whether there are furtherquestions. If there are no further questions, the rendering engine 204generates at step 510 an instance document in HTML format on the basisof responses provided by the user, and the instance document is thendisplayed by the web browser, as shown in FIG. 7.

The parts of the text that are dependent on answers provided by the userare provided as hypertext anchors 702, allowing the user to view thequestions and responses that resulted in the insertion of that text in apopup window 704 by moving their mouse over the text. If, at step 512,the user selects the hypertext anchor 702, the processing engine 202generates a new interview round including the relevant question,allowing the user to provide a different response to that question.Questions dependent on the new response are then presented to the userat step 506 until the processing engine 202 determines that all thenecessary information has been provided. A new HTML rendering of theinstance XML document is then generated at step 510 and displayed by theweb browser.

When the user is satisfied with the instance document, one of a numberof buttons included near the top of the HTML instance document can beselected to generate an output document. The button selected determinesthe format of the output format. For example, FIG. 7 shows a button 706for creating an output document in the Adobe® portable document format(PDF). However, the document can alternatively generated in HTML(without controls), XML, or in rich text format (RTF). Check boxes 708are also provided in order to allow the user to determine the content ofthe output document, whether it will contain the instance document text,editorial notes pertaining to the use of the document, and/or theinterview questions and answers on which the document was based. Afurther check box 710 allows the user to select whether the outputdocument will be write protected.

Controls 712 are also provided for storing responses on the system asstored response data 215 and for applying stored responses to the sourcedocument they came from, or to another source document that uses some ofthe same logic sources, and for processing groups of related documents.

It is useful to be able to store the response data, so that if a userwishes to modify some of the answers they have given in an earliersession, they can start by applying the stored response data to thesource document, rather than having to answer all the questions againthemselves. When an answer file containing stored response data isloaded, the questions and answers are displayed to the user in an HTMLform. After the user has modified the responses as appropriate, andsubmitted the form (by selecting a “next” button), those interview itemsare provided to the evaluator module 402. When, in the course ofevaluating the source document to which those answers are being applied,an interview item is encountered, there will be no need to ask the Javacontroller servlet 218 for a response to that item, if the response hasalready been provided via the answer file mechanism.

In a similar way, the Java controller servlet 218 can invoke theprocessing engine 202, applying a collection of response data to theseveral source documents comprising a group of related documents, andthen invoke the rendering engine 204 to display the resulting instancedocuments in the user's browser, or save them to disk. It will beapparent that whether each document is processed then rendered, or alldocuments are processed then all rendered, depends on the controllerservlet implementation (i.e., how it invokes the processing engine 202and the rendering engine 204).

Thus the document assembly system provides an efficient, yet flexiblemeans to generate and modify instance documents for differentcircumstances. The source documents 208, document grammars 212, logicsources 210 and logic grammars 214 are typically created and maintainedby an administrator of the system in accordance with the needs of thesystem's users. For example, a legal firm will create precedents forparticular circumstances, e.g., contracts, as source documents 208,together with their associated logic sources 210 and grammars 212, 214.The creation and maintenance of these files 110 is performed using theeditor 112. The actual assembly of these files 110 into instancedocuments is initiated by end-users of the system accessing the systemusing a web browser.

The document assembly system is described in more detail below withreference to examples of the data files 110 used by the system. An XMLsource document used by the document assembly system for generatinginstance letters is presented below in its entirety. Portions of thissource document are then described in detail to illustrate variousfeatures of the document assembly system.

<?xml version=“1.0” encoding=“UTF-8”?> <!DOCTYPE Letter SYSTEM“file:///home/speedlegal/dtd/xhtml-letter/dtd/xhtml-letter- v2.dtd”><Letter>  <?SpeedLegal   <LogicSources>    <LogicSourceID=“LogicSource_1” uri=“/files/logic/LS1WD.lgc”/>    <LogicSourceID=“LogicSource_2” uri=“/files/logic/LS2WD.lgc”>     <PartyMapping>     <PartyMap From=“Contractor” To=“Employee”>       <PartyDetailMapFrom=“Shortname” To=“Firstname”/>       <PartyDetailMap From=“Fullname”To=“Firstname”/>      </PartyMap>     </PartyMapping>    </LogicSource>  </LogicSources>  ?>  <?SpeedLegal   <MetaInformation>    <rdf:RDFxmlns:dc=“http://purl.org/dc/elements/1.1/”xmlns:rdf=“http://www.w3.org/TR/WD-rdf-syntax-ns#”>    <rdf:Description>      <Metadata>       <dc:Type Genesis=“Original”Status=“Unapproved” Use=“Precedent”/>       <dc:Title>Lettertemplate</dc:Title>       <dc:Description>Template businessletter</dc:Description>      <dc:Subject><Keyword>Letter</Keyword></dc:Subject>      <dc:Creator>        <Name>SpeedLegal</Name>       <Organisation>SpeedLegal</Organisation>       <md.ContactDetails>         <md.Address>Level 4, 85 Queen Street,Melbourne, Victoria</md.Address>         <md.Phone>+61 3 96700141</md.Phone>         <md.Email>info@speedlegal.com</md.Email>        <md.Fax>+61 3 9670 0142</md.Fax>        </md.ContactDetails>      </dc:Creator>       <RevisionHistory> <Revision><dc:Contributor><Name>SpeedLegal</Name></Organisation>SpeedLegal</Organisation><md.ContactDetails><md.Address>Level 4, 85 Queen Street,Melbourne, Victoria</md.Address><md.Phone>+61 3 96700141</md.Phone><md.Email>info@speedlegal.com</md.Email><md.Fax>+61 39670 0142</md.Fax></md.ContactDetails></dc:Contributor><dc:Date>6/2/200213:49</dc:Date><What ChangeType=“BrandNew”>Lettercreation</What></Revision>       </RevisionHistory>      </Metadata>    </rdf:Description>    </rdf:RDF>   </MetaInformation>  ?> <LetterHead>   <Date/>   <Salutation/>  </LetterHead>  <LetterBody>  <p>    <?SpeedLegal     <Condition IDREF=“PaidLeave”LogicSource=“LogicSource_1”/>    ?>    <?SpeedLegal     <PartyReferenceIDREF=“Employee” LogicSource=“LogicSource_1” Style=“Pronoun”Type=“PartyDetail_1”/>    ?> shall be eligible for paid leave.</p>   <p>   <?SpeedLegal     <Notes>      <Note CompletionInstruction=“false”ShowExternalUsers=“false” UserLevel=“Non-Specialist”>      <NoteTitle>Paid and Unpaid Leave</NoteTitle>      <NoteBody><p>All employees can request <b>unpaid</b>leave</p><p>Only <b>Full-time</b> or <b>Part-time</b> employees who haveaccrued leave can request <b>paid</b> leave.</p></NoteBody>      </Note>    </Notes>    ?>    <?SpeedLegal     <PartyReference IDREF=“Employee”LogicSource=“LogicSource_1” Style=“Firstname” Type=“PartyDetail_0”/>   ?> may request <?SpeedLegal <InsertReusablePhraseIDREF=“PaidOrUnpaidLeave” LogicSource=“LogicSource_1”/>?> by filling ina request form at least one month prior to the earliest daterequired.</p>   <p>    <?SpeedLegal <ConditionIDREF=“AmountOfLeave.negotiate” LogicSource=“LogicSource_1”/>?>Theamount of leave is negotiated with the employee.</p>   <p>   <?SpeedLegal <Condition IDREF=“AmountOfLeave.award”LogicSource=“LogicSource_1”/>?>The amount of leave is determinedaccording to the relevant award.</p>   <p>The employee has the followingleave entitlements: <object>     <table>      <tbody>       <tr>       <?SpeedLegal <ArrayRowIterator repeat=“NumberOfLeaveTypes”/>?>       <td><?SpeedLegal <ArrayReference IDREF=“LeaveType”/>?> </td>       <td><?SpeedLegal <ArrayReference IDREF=“LeaveAmount”/>?> </td>      </tr>      </tbody>     </table>    </object>   </p>  <?SpeedLegal    <SmartModule uri=“/home/jml/termination.sm”>    <PartyMapping>      <PartyMap From=“Contractor” To=“Employee”>      <PartyDetailMap From=“Shortname” To=“Firstname”/>      <PartyDetailMap From=“Fullname” To=“Firstname”/>      </PartyMap>    </PartyMapping>    </SmartModule>   ?>  </LetterBody>  <LetterTail>  <Closing/>   <Sender/>  </LetterTail> </Letter>

This source document includes several processing instructions (PIs) thatbegin with “<?SpeedLegal” and end with “?>”. The data within theprocessing instruction, i.e., between these two strings, resembles oneor more XML elements. This allows an application to receive the data andparse it as XML, with the various benefits which that entails. It willbe apparent to the skilled addressee that this structure is in conflictwith the XSLT 1.0 specification, which specifically prohibits an XSLTprocessor from constructing PI data in this form. In what follows, it isconvenient to refer to the PI data as if it were an XML element.

Some of the PIs in the above source document include within them aLogicSource XML element whose purpose is to specify the location orlocations, outside of the source XML document itself, where the systemcan find the material necessary to process other processing instructionsencountered within the document, such as the Condition instruction inthe above example. For example, a logic source is identified in theabove example as follows:

<LogicSources>  <LogicSource ID=“LogicSource_1”uri=“/files/logic/LS1WD.lgc”/>

The LogicSource sub-element of the LogicSources element specifies auniversal resource indicator (URI) at which the corresponding logicsource can be found, and assigns an ID reference name to it. Many of theprocessing instructions throughout the example source document abovecontain an IDREF reference to one of the ID reference names of thelisted logic sources, which is used to identify the URI of thecorresponding logic source. Thus the first logic source referred to inthe XML document is located at the URI “/files/logic/LS1WD.lgc” and isreferred to at other places in the source document by the ID reference“LogicSource_(—)1”. This logic source is provided below.

<?xml version=“1.0” encoding=“UTF-8”?> <!DOCTYPE LogicFile PUBLIC“-//SpeedLegal//SpeedLegal Logic for SmartEditor 1v0//EN”“/home/speedlegal/dtd/logic.dtd”> <LogicFile>  <MetaInformation><rdf:RDF> <rdf:Description> <Metadata> <dc:Type Genesis=“Original”Status=“Unapproved” Use=“Precedent”/> <dc:Title>[ ]</dc:Title><dc:Description>[ ]</dc:Description> <dc:Subject> <Keyword>[ ]</Keyword></dc:Subject> <dc:Creator> <Name>SpeedLegal</Name><Organisation>SpeedLegal</Organisation> <md.ContactDetails><md.Address>Level 4, 85 Queen Street, Melbourne, Victoria</md.Address><md.Phone>+61 3 9670 0141</md.Phone><md.Email>info@speedlegal.com</md.Email> <md.Fax>+61 3 96700142</md.Fax> </md.ContactDetails> </dc:Creator> <RevisionHistory><Revision> <dc:Contributor> <Name>SpeedLegal</Name><Organisation>SpeedLegal</Organisation> <md.ContactDetails><md.Address>Level 4, 85 Queen Street, Melbourne, Victoria</md.Address><md.Phone>+61 3 9670 0141</md.Phone><md.Email>info@speedlegal.com</md.Email> <md.Fax>+61 3 96700142</md.Fax> </md.ContactDetails> </dc:Contributor> <dc:Date>5/2/200211:4</dc:Date> <What ChangeType=“BrandNew”> metadata</What> </Revision></RevisionHistory> </Metadata> </rdf:Description> </rdf:RDF> </MetaInformation>  <PartiesSetup> <Party Assessable=“true”ID=“Employee”> <DisplayName>Employee</DisplayName> <Role>The person tobe offered a position under this letter.</Role> <PartyDetails><PartyDetail ID=“PartyDetail_0” Name=“Firstname”> <ValueGender=“Unspecified” Number=“Unspecified”> <InsertUserTextIDREF=“EmployeeFirstname”/> </Value> </PartyDetail> <PartyDetailID=“PartyDetail_1” Name=“Pronoun”> <Value Gender=“Unspecified”Number=“Singular”>He</Value> <Value Gender=“Female”Number=“Singular”>She</Value> <Value Gender=“Unspecified”Number=“Plural”>They</Value> </PartyDetail> </PartyDetails> </Party><Party Assessable=“true” ID=“Employer”><DisplayName>Employer</DisplayName> <Role>The person who will offer toengage the employee under this letter.</Role> <PartyDetails><PartyDetail ID=“PartyDetail_2” Name=“Name”> <Value Gender=“Unspecified”Number=“Unspecified”>SpeedLegal</Value> </PartyDetail> </PartyDetails></Party>  </PartiesSetup>  <LogicSources/>  <LogicSetup><UserTextQuestion Columns=“20” ID=“LetterSubject” Rows=“1” Type=“Text”><Question>What is the subject of this letter?</Question> <Topic>Subjectof Letter</Topic> </UserTextQuestion> <MultipleChoiceQuestionID=“Employment_type”> <QuestionType KeyQuestion=“true”/> <Question>Onwhat basis will <PartyReference IDREF=“Employee” Style=“Firstname”Type=“PartyDetail_0”/> be employed?</Question> <Topic>Position andduties</Topic> <SelectionRules AnswerUsing=“Default”Cardinality=“Single” Device=“Checkbox”/> <Responses> <Response><SelectionCriteria Default=“Checked”/> <Prompt>On a full timebasis</Prompt> <SetValueTo>FullTime</SetValueTo> <Notes> <NoteCompletionInstruction=“false” ShowExternalUsers=“false”UserLevel=“Non-Specialist”> <NoteTitle>Full Time Employees</NoteTitle><NoteBody> <p>Full time employees are required to work at least thehours specified in the award</p> <p>They are elligible formaternity/paternity leave as well as annual and sick leave</p></NoteBody> </Note> </Notes> </Response> <Response> <SelectionCriteriaDefault=“Unchecked”/> <Prompt>On a part time basis</Prompt><SetValueTo>PartTime</SetValueTo> </Response> <Response><SelectionCriteria Default=“Unchecked”/> <Prompt>On a casualbasis</Prompt> <SetValueTo>Casual</SetValueTo> </Response> </Responses></MultipleChoiceQuestion> <Condition ID=“Employment_type.FullTime”><Test IDREF=“Employment_type” Value=“FullTime”/>  </Condition> <Condition ID=“Employment_type.PartTime”> <Test IDREF=“Employment_type”Value=“PartTime”/>  </Condition>  <ConditionID=“Employment_type.Casual”> <Test IDREF=“Employment_type”Value=“Casual”/>  </Condition>  <UserTextQuestion Columns=“20”ID=“Commencement” Rows=“1” Type=“Text”> <Question>On what date will<PartyReference IDREF=“Employee” Style=“Firstname”Type=“PartyDetail_0”/>&apos;s employment commence?</Question><Topic>Position</Topic>  </UserTextQuestion>  <UserTextQuestionColumns=“20” ID=“NumberOfLeaveTypes” Rows=“1” Type=“PositiveInteger”><Question>How many distinct types of leave is the employee entitledto?</Question> <Topic>Leave Table</Topic>  </UserTextQuestion> <UserTextQuestion Columns=“20” ID=“LeaveType” Rows=“1” Type=“Text”><Question>Type of Leave?</Question> <Topic>Leave Table</Topic> </UserTextQuestion>  <UserTextQuestion Columns=“20” ID=“LeaveAmount”Rows=“1” Type=“Text”> <Question>Number of Weeks?</Question> <Topic>LeaveTable</Topic>  </UserTextQuestion>  <Condition ID=“PaidLeave”> <Or><UseCondition IDREF=“Employment_type.FullTime”/> <UseConditionIDREF=“Employment_type.PartTime”/> </Or>  </Condition> <UserTextQuestion Columns=“20” ID=“EmployeeFirstname” Rows=“1”Type=“Text”> <Question>Please type the <PartyReference IDREF=“Employee”Style=“Firstname” Type=“PartyDetail_0”/>&apos;s first name</Question><Topic>Employee Setup</Topic>  </UserTextQuestion>  <ReusablePhraseID=“PaidOrUnpaidLeave”>unpaid <ConditionalPhraseCondition=“PaidLeave”>or paid</ConditionalPhrase> leave</ReusablePhrase> <MultipleChoiceQuestion ID=“AmountOfLeave”> <QuestionTypeKeyQuestion=“false”/> <Question>How much leave is <PartyReferenceIDREF=“Employee” Style=“Firstname” Type=“PartyDetail_0”/> entitledto?</Question> <Topic>Setup</Topic> <SelectionRules AnswerUsing=“Bias”Cardinality=“Single” Device=“Checkbox”/> <Responses> <Response><SelectionCriteria Default=“Unchecked”> <PartyAssessmentAssessment=“Best” IDREF=“Employer”/> </SelectionCriteria> <Prompt>Awardentitlements</Prompt> <SetValueTo>award</SetValueTo> </Response><Response> <SelectionCriteria Default=“Unchecked”> <PartyAssessmentAssessment=“Worst” IDREF=“Employer”/> </SelectionCriteria> <Prompt>Bynegotiation with <PartyReference IDREF=“Employer” Style=“Name”Type=“PartyDetail_2”/> </Prompt> <SetValueTo>negotiate</SetValueTo></Response> </Responses> </MultipleChoiceQuestion> <ConditionID=“AmountOfLeave.award”> <Test IDREF=“AmountOfLeave” Value=“award”/></Condition> <Condition ID=“AmountOfLeave.negotiate”> <TestIDREF=“AmountOfLeave” Value=“negotiate”/> </Condition>  </LogicSetup></LogicFile>

Because the information necessary to process processing instructionsencountered within the source document are stored outside the sourcedocument, this information can be stored in an XML format and cantherefore be validated against an XML schema or DTD. The DTD used by thedocument assembly system for validating logic sources 210 is as follows:

<!ELEMENT LogicFile (MetaInformation,_PartiesSetup, LogicSources,LogicSetup)> <!ELEMENT LogicSources (LogicSource)*> <!ELEMENTLogicSource (PartyMapping)> <!ATTLIST LogicSource uri CDATA #REQUIRED ><!ELEMENT PartyMapping (PartyMap*)> <!ELEMENT PartyMap(PartyDetailMap)+> <!ATTLIST PartyMap From NMTOKEN #REQUIRED To ID#REQUIRED > <!ELEMENT PartyDetailMap EMPTY> <!ATTLIST PartyDetailMapFrom NMTOKEN #REQUIRED To ID #REQUIRED > <!ENTITY % HtmlParagraphMarkup“b |i| a ”> <!ENTITY % MappablePCDATA “(#PCDATA | PartyReference)*”><!ENTITY % SmartsPhraseLevelDeclarations “ ReusablePhrase |UserTextQuestion ”> <!ENTITY  %  SmartsPhraseLevelInsertions  “| InsertReusablePhrase  | ConditionalPhrase | InsertUserText”> <!ENTITY %SmartsConditions “ Condition IDREF #IMPLIED ”> <!ENTITY %SmartsIdRequired “ID ID #REQUIRED”> <!ENTITY % SmartsIdImplied “ID ID#IMPLIED”> <!ENTITY % SmartsIDREF “IDREF IDREF #REQUIRED ”> <!ENTITY %SmartIDREF “IDREF IDREF #REQUIRED ”> <!ENTITY % SmartsPCDATA “(#PCDATA |InsertUserText | InsertReusablePhrase | ConditionalPhrase )*”> <!ELEMENTMetaInformation (rdf:RDF)> <!ELEMENT rdf:RDF (rdf:Description)><!ATTLIST rdf:RDF xmlns:rdf CDATA #FIXED“http://www.w3.org/TR/WD-rdf-syntax-ns#” xmlns:dc CDATA #FIXED“http://purl.org/dc/elements/1.1/” > <!ELEMENT rdf:Description(Metadata)> <!ELEMENT Metadata (dc:Type, dc:Title, dc:Source?,dc:Description, dc:Subject, dc:Creator, dc:Publisher?, dc:Relation*,RevisionHistory, PlannedEnhancements?)> <!ELEMENT dc:Type EMPTY><!ATTLIST dc:Type Genesis (Original | Copy | Link) “Original” Use(Precedent | Transaction) “Precedent” Status (Unapproved | Approved)“Unapproved” > <!ELEMENT dc:Title (#PCDATA)> <!ELEMENT dc:Source(#PCDATA)> <!ELEMENT dc:Description (#PCDATA)> <!ELEMENT dc:Subject(Keyword*)> <!ELEMENT Keyword (#PCDATA)> <!ELEMENT dc:Creator (Name,Organisation, md.ContactDetails)> <!ELEMENT Name (#PCDATA)> <!ELEMENTOrganisation (#PCDATA)> <!ELEMENT md.ContactDetails (md.Address |md.Phone | md.Email | md.Fax)+> <!ELEMENT md.Address (#PCDATA)><!ELEMENT md.Phone (#PCDATA)> <!ELEMENT md.Email (#PCDATA)> <!ELEMENTmd.Fax (#PCDATA)> <!ELEMENT dc:Publisher (Name, Organisation,md.ContactDetails)> <!ELEMENT dc:Relation (UsedBy?, MatterNumber?,Client?, Other*)> <!ELEMENT UsedBy (#PCDATA)> <!ELEMENT MatterNumber(#PCDATA)> <!ELEMENT Client (#PCDATA)> <!ELEMENT Other (Field,FieldValue)> <!ELEMENT Field (#PCDATA)> <!ELEMENT FieldValue (#PCDATA)><!ELEMENT PlannedEnhancements (Enhancement*)> <!ELEMENT Enhancement(dc:Contributor, dc:Date, What)> <!ELEMENT RevisionHistory (Revision*)><!ELEMENT Revision (dc:Contributor, dc:Date, What)> <!ELEMENTdc:Contributor (Name, Organisation, md.ContactDetails)> <!ELEMENTdc:Date (#PCDATA)> <!ELEMENT What (#PCDATA)> <!ATTLIST What ChangeType(MajorRework | MinorChanges | BrandNew | ExtraContent | Update)“BrandNew” > <!ELEMENT PartiesSetup (Party*)> <!ELEMENT Party(DisplayName, Role, PartyDetails)> <!ATTLIST Party %SmartsIdRequired;Assessable (true | false) “true” > <!ELEMENT DisplayName (#PCDATA)><!ELEMENT Role %MappablePCDATA;> <!ELEMENT PartyDetails (PartyDetail+)><!ELEMENT PartyDetail (Value+)> <!ATTLIST PartyDetail Name NMTOKEN#REQUIRED %SmartsIdRequired; > <!ELEMENT Value %SmartsPCDATA;> <!ATTLISTValue Gender (Male | Female | Neuter | Unspecified) “Unspecified” Number(Singular | Plural | Unspecified) “Unspecified” > <!ELEMENTPartyReference EMPTY> <!ATTLIST PartyReference %SmartIDREF; Type IDREF#REQUIRED Style NMTOKEN #IMPLIED > <!ELEMENT  LogicSetup  (Condition  | MultipleChoiceQuestion  | %SmartsPhraseLevelDeclarations;)*> <!ENTITY %booleanSubstitute “ Test | UseCondition | And | Or | Not ”> <!ELEMENTCondition (True | False | %booleanSubstitute;)> <!ATTLIST Condition%SmartsIdRequired; > <!ELEMENT True EMPTY> <!ELEMENT False EMPTY><!ELEMENT Test EMPTY> <!ATTLIST Test uri CDATA #IMPLIED %SmartsIDREF;Value CDATA #REQUIRED > <!ELEMENT And ((%booleanSubstitute;),(%booleanSubstitute;))> <!ELEMENT Or ((%booleanSubstitute;),(%booleanSubstitute;))> <!ELEMENT Not (%booleanSubstitute;)> <!ELEMENTUseCondition EMPTY> <!ATTLIST UseCondition uri CDATA #IMPLIED%SmartsIDREF; > <!ELEMENT Question %MappablePCDATA;> <!ELEMENT Topic%MappablePCDATA;> <!ELEMENT MultipleChoiceQuestion (QuestionType,Question, Topic, Notes?, SelectionRules, Responses)> <!ATTLISTMultipleChoiceQuestion %SmartsIdRequired; > <!ELEMENT QuestionTypeEMPTY> <!ATTLIST QuestionType KeyQuestion (true | false) “true” ><!ELEMENT Responses (Response, Response+)> <!ELEMENT SelectionRulesEMPTY> <!ATTLIST SelectionRules Device (Checkbox | DropdownList)“Checkbox” AnswerUsing (Default | Bias) “Bias” Cardinality (Single |Multiple) “Single” > <!ELEMENT Response (SelectionCriteria, Prompt,SetValueTo, Notes?)> <!ELEMENT SelectionCriteria (PartyAssessment)*><!ATTLIST SelectionCriteria Default (Checked | Unchecked) “Unchecked” ><!ELEMENT PartyAssessment EMPTY> <!ATTLIST PartyAssessment %SmartsIDREF;Assessment (Worst | Bad | Neutral | Good | Best) “Neutral” > <!ELEMENTPrompt %MappablePCDATA;> <!ELEMENT SetValueTo (#PCDATA)> <!ELEMENTUserTextQuestion (Question, Topic, DefaultText?, Notes?)> <!ATTLISTUserTextQuestion %SmartsIdRequired; Columns (1 | 2 | 3 | 4 | 5 | 10 | 15| 20 | 25 | 30 | 40 | 50 | 60 | 70) “20” Rows (1 | 2 | 3 | 4 | 5 | 6 | 7| 8 | 9 | 10| 12 | 14 | 15 | 16 | 18 | 20 | 25 | 30) “1” Type (Text |Duration | Time | Date | Decimal | Integer) “Text” > <!ELEMENTDefaultText (#PCDATA)> <!ELEMENT InsertUserText EMPTY> <!ATTLISTInsertUserText %SmartIDREF; > <!ELEMENT ReusablePhrase (#PCDATA%SmartsPhraseLevelInsertions; )*> <!ATTLIST ReusablePhrase%SmartsIdRequired; > <!ELEMENT InsertReusablePhrase EMPTY> <!ATTLISTInsertReusablePhrase %SmartIDREF; > <!ELEMENT  ConditionalPhrase (#PCDATA  |  PartyReference %SmartsPhraseLevelInsertions; )*> <!ATTLISTConditionalPhrase %SmartsConditions; > <!ELEMENT Notes (Note)*><!ELEMENT Note (NoteTitle, NoteBody)> <!ATTLIST Note UserLevel(Specialist | Non-Specialist) “Non-Specialist” ShowExternalUsers (true |false) “false” CompletionInstruction (true | false) “false” > <!ELEMENTNoteTitle (#PCDATA)> <!ELEMENT NoteBody (p)+> <!ELEMENT p (#PCDATA |%HtmlParagraphMarkup;)*> <!ELEMENT b (#PCDATA)> <!ELEMENT i (#PCDATA)><!ELEMENT a (#PCDATA)> <!ATTLIST a href CDATA #REQUIRED target CDATA#FIXED “_blank”>

Another advantage of separating logic source files 210 from documentsource files 208 is that the logic source files 210 can also be re-usedin conjunction with other XML documents, simplifying maintenance. Forsimilar reasons, it is convenient to store logic information in separatefiles rather than, for example, one monolithic logic file. This allowsrelated information to be grouped together, and only the logiccomponents that are required need to be re-used with a given sourcedocument.

It will be apparent that this information could alternatively be storedin a database rather than separate XML files. Separate XML files arepreferred because they can be easily arranged in a hierarchical filesystem. However, if a logic source which is in use is moved, then a baseXML document that refers to the logic source will include an incorrectURI, and will need to be updated. In an alternative embodiment, therepository 208 in which the source documents are stored detects the factthat the logic source has been moved, and updates the references to thatlogic source automatically, or alternatively, advises a URI resolver(the purpose of which is to translate old locations to actual locations)of the new location. This approach can be implemented with file systemsthat allow extra code to be executed automatically when a file is moved,renamed or deleted. Many WebDAV server implementations are provided withsource code, which would enable a document assembly system which used awebDAV server as its repository 208 to implement this.

In yet a further alternative embodiment, the document assembly systemincludes a single resource that authoritatively associates the name of alogic source with its location, so that in a reference to a logicsource, a source document includes the name of the resource known to thesystem (together with the party mapping being used, as to which seefurther below). In this embodiment, only that single resource needs tobe updated when a logic source is moved or renamed.

A logic source can refer to one or more other logic sources. Forexample, FIG. 8 shows a first logic source 802 that builds additionallogic on top of that available in second 804 and third 806 logicsources. The third logic source 806, in turn, builds additional logic ontop of a fourth logic source 808. However, the base XML document 812only refers to the first 802 and a fifth 818 logic sources. Thus aconvention is needed as to the scope or “visibility” of logic. Theconvention used in the preferred embodiment is that the only logicsources visible in a particular document (either an XML source documentor a logic source) are those declared in that document's <LogicSources>element. Consequently, if the base XML document 812 needed to use acondition defined in the third logic source 806, it would need to importthat logic source in its <LogicSources> element. This would be achievedby an administrator editing the source document 812 using the editor112.

FIG. 8 also shows the base XML document 812 reusing an XML fragment 814by reference. A “SmartModule” processing instruction is used for thispurpose because use of the source document of the standard XML inclusionmechanism Xinclude, documented at http://www.w3.org/TR/xinclude/, wouldinvalidate the source document unless the grammar for the sourcedocument specifically allowed its use. In FIG. 8, the XML fragment 814imports a sixth logic source 816. The latter is not visible to the baseXML document 812.

Assembled documents often refer to one or more parties. For example, alegal document might refer to the parties involved in an agreement ofsome kind. In such cases there are often only two parties involved, butin some circumstances there may be many parties. A logic sourcespecifies the parties known to it, in its PartiesSetup element.

A party mapping is a child on a logic source import that allows partiesused in a logic source to be mapped to parties used in a documentimporting the logic source. This makes it possible for a logic sourcewhich, for example, refers to a Plumber and a Homeowner, to be used in adocument between a Banker and a Customer.

A party mapping chain is a chain of party mappings between a base XMLdocument and a logic source. It will be evident that a party mappingchain can swap two parties around e.g., if the LogicSource importstatement in the base XML document 812 for the first logic source 802said, in effect, “Employer becomes Employee and Employee becomesEmployer”. Thus two references to the same physical logic source areregarded as logically the same if and only if their respective partymapping chains result in the same party mapping.

It is not an error to import the same logic source twice in a singleLogicSources statement (allocating each occurrence a distinct ID). Thisallows one physical question or condition to be used for two logicalquestions by defining different party mappings in each LogicSourceimport statement.

In addition to those described above, the example source document andlogic source above include seven other types of processing instruction:

-   -   (i) Condition    -   (ii) InsertReusablePhrase    -   (iii) InsertUserText    -   (iv) PartyReference    -   (v) ArrayRowIterator    -   (vi) SmartModule    -   (vii) Notes    -   (viii) MetaInformation

For half of these, there is a correspondence between a processinginstruction in a source XML document and an element in a referencedlogic source. That is, when software manipulates or interprets theprocessing instruction, it does so in conjunction with the correspondingelement in the logic source. This correspondence is as follows:

Processing Instruction LogicSource Condition ConditionInsertReusablePhrase ReusablePhrase InsertUserText UserTextQuestionPartyReference Party

ArrayRowIterator, SmartModule, Notes and MetaInformation are exceptionsto this—an ArrayRowIterator is independent, as is Notes andMetaInformation, while a SmartModule has a correspondence with afragment of XML stored at some other URI.

A Condition processing instruction specifies by convention that itsparent element should only be included in the instance document if theassociated condition evaluates to true. For example, the followingcondition is taken from the example source document given above.

<p> <?SpeedLegal <Condition IDREF=“AmountOfLeave.negotiate”LogicSource=“LogicSource_1”/>?>The amount of leave is negotiated withthe employee.</p>

This means that the <p> element will only be included in an instancedocument generated from this source document if the ConditionAmountOfLeave.negotiate in the logic source named “LogicSource_(—)1” istrue. It will be apparent that alternative embodiments could bedeveloped to implement the condition is other ways. For example, theCondition could by convention apply to the following sibling, orCondition open and Condition close processing instructions could be usedto surround the XML to which the condition is to apply. However, neitherof these approaches is preferred. In the first case, there may be nofollowing sibling. In the second case, if the open and close processinginstructions are not properly nested so that they precede and follow,respectively, a matching pair of tags, then the resulting instancedocument would not be well-formed. Similarly, the syntax of theCondition PI could have been written in various ways, some of whichinclude data that looks like XML, and others that do not, including:

(i) <?SpeedLegal <Condition IDREF=“AmountOfLeave.negotiate”LogicSource=“LogicSource_1”/>?> (ii) <?SpeedLegal <Logictype=“condition” IDREF=“AmountOfLeave.negotiate”LogicSource=“LogicSource_1”/>?> (iii) <?Condition <dataIDREF=“AmountOfLeave.negotiate” LogicSource=“LogicSource_1”/>?> (iv)<?Condition IDREF=“AmountOfLeave.negotiate”LogicSource=“LogicSource_1”?> (v) <?ConditionIDREF=“AmountOfLeave.negotiate”; LogicSource=“LogicSource_1”?> (vi)<?Condition LogicSource_1#AmountOfLeave.negotiate”?>

However, the first of these is the form used in the preferredembodiment.

The IDREF attribute of a condition PI specifies the ID of the conditionto be tested; the LogicSource attribute is an IDREF to the logic sourcein which the condition is defined. For example, the logic source filewith an IDREF of “LogicSource_(—)1” and listed above contains thedefinition of the AmountOfLeave.negotiate condition, as follows:

<Condition ID=“AmountOfLeave.negotiate”>  <Test IDREF=“AmountOfLeave”Value=“negotiate”/> </Condition>

This means that the condition will evaluate to true if the responsegiven for the question named (i.e., with an IDREF equal to)“AmountOfLeave” has the value “negotiate”. The question “AmountOfLeave”is a multiple choice question defined in the logic source, as follows:

<MultipleChoiceQuestion ID=“AmountOfLeave”>  <QuestionTypeKeyQuestion=“false”/>  <Question>How much leave is <PartyReferenceIDREF=“Employee”      Styte=“Firstname”     Type=“PartyDetail_0”/>entitled to?</Question>  <Topic>Setup</Topic> <SelectionRules AnswerUsing=“Bias” Cardinality=“Single”     Device=“Checkbox”/>  <Responses>   <Response>    <SelectionCriteriaDefault=“Unchecked”>     <PartyAssessment Assessment=“Best”IDREF=“Employer”/>    </SelectionCriteria>    <Prompt>Awardentitlements</Prompt>    <SetValueTo>award</SetValueTo>   </Response>  <Response>    <SelectionCriteria Default=“Unchecked”>    <PartyAssessment Assessment=“Worst” IDREF=“Employer”/>   </SelectionCriteria>    <Prompt>By negotiation    with<PartyReference IDREF=“Employer”     Style=“Name” Type=“PartyDetail_2”/>   </Prompt>    <SetValueTo>negotiate</SetValueTo>   </Response> </Responses> </MultipleChoiceQuestion>

In this example, the MultipleChoiceQuestion element's QuestionType childhas value “false” for attribute KeyQuestion. This means that theprocessing engine 202 is free to attempt to answer this question itself(i.e., without interacting with any external agent) using its scoringprocedure if the user or software invoking the Processing Engine 202indicated they only wished to be asked Key Questions.

If the SelectionRules element has value “Bias” for the AnswerUsingattribute, as is the case here, then the processing engine 202 scoreseach response based on the values contained in its SelectionCriteriachild and which party the user or software invoking the ProcessingEngine 202 indicated they wish to favour. Alternatively, if theSelectionRules element has value “Default” for the AnswerUsingattribute, then the processing engine 202 selects the response for whichthe SelectionCriteria element's “Default” attribute has value “Checked”.For example, FIG. 11 shows a screenshot of a web browser windowdisplaying this question in HTML generated by the Java Controllerservlet 218 of the document assembly system.

In the above example, the MultipleChoiceQuestion is defined in the logicsource that also defines the condition. However, a definition in adifferent logic source can be used, assuming that different logic sourcewas declared in the LogicSources element (of the logic source whichdefines the condition), by including its IDREF name (i.e., the nameassigned to it in the logic sources element) in the Test element, forexample:

-   <Test IDREF=“AmountOfLeave” Value=“negotiate”    LogicSource=“LogicSource804”/>

A condition can be defined in terms of other conditions, using booleanlogic operators. In the example, the Condition PaidLeave is defined asfollows:

<Condition ID=“PaidLeave”>  <Or>   <UseConditionIDREF=“Employment_type.FullTime”/>   <UseConditionIDREF=“Employment_type.PartTime”/>  </Or> </Condition>

This condition will be true if either the conditionEmployment_type.FullTime is true or the conditionEmployment_type.PartTime is true.

It will be evident that condition PIs as described above can only beattached to elements. The question arises—what if it is desired toattach a condition to some text which is not tagged (or it is notdesired to tag, or, because of the grammar, cannot be tagged) with anelement to which a condition can be attached. There are several possiblesolutions to this. One possibility is to define opening and closingCondition PIs that surround the text in question. However, this approachhas drawbacks already adverted to above. In the preferred embodiment,the text is defined in a logic source, and an “InsertReusablePhrase”processing instruction is used to refer to it in the source document.

There is an InsertReusablePhrase in the example XML document above:

<p>..may request <?SpeedLegal <InsertReusablePhraseIDREF=“PaidOrUnpaidLeave” LogicSource=“LogicSource_1”/>?> by filling ina request form at least one month prior to the earliest daterequired.</p>

The corresponding ReusablePhrase with ID “PaidOrUnpaidLeave” is definedin the logic source as follows:

<ReusablePhrase ID=“PaidOrUnpaidLeave”>unpaid <ConditionalPhraseCondition=“PaidLeave”>or paid</ConditionalPhrase> leave</ReusablePhrase>

Thus a ReusablePhrase can contain not only text, but other things whichare evaluated. One of these is a “ConditionalPhrase”. This is an elementwhich is defined in the logic source schema or DTD, mainly for thepurpose of allowing a condition to be attached. In this way aReusablePhrase can be used to conditionally insert text into the XMLdocument in the absence of an element to which a condition can otherwisebe attached. In alternative embodiments, a condition could be attacheddirectly to the ReusablePhrase element as an attribute, or a newprocessing instruction defined which specifies both a condition and thetext to be inserted if the condition is true.

Information entered by a user in response to a question can also beinserted into an instance document. For example, suppose that the sourcedocument listed above included the following processing instruction:

<?SpeedLegal  <InsertUserText IDREF=“LetterSubject” LogicSource= “LogicSource_1”/> ?>

The rendering engine 204 processes this instruction by inserting, in theinstance document, the value (i.e., the response provided by the user)of the user text question with ID “LetterSubject” that is defined in thelogic source “LogicSource_(—)1”.

That user text question is defined in the logic source as follows:

<UserTextQuestion Columns=“20” ID=“LetterSubject” Rows=“1” Type=“Text”> <Question>What is the subject of this letter?</Question> <Topic>Subject of Letter</Topic> </UserTextQuestion>

The type attribute restricts the allowed type of input to the specifiedformat, which is one of text, duration, time, date, decimal, or integer.In this example, the user can enter free text.

In an alternative embodiment, users are given greater flexibility todefine and use their own variable types. This gives the user the abilityto validate a broader and more complex range of data types than ispossible with a closed set. For example, a UserTextQuestion can beassigned a defined data type as follows:

<UserTextQuestion AskEachRepeat=“false” Columns=“20” ID=“HourlyRate”Rows=“1” Type=“DollarValue”>   <Question>What is <PartyReferenceIDREF=“Recruit” Style=“Shortname”Type=“PartyDetail_10”/></PartyReference> &amp;apos;s hourly rate?</Question>   <Topic>Salary, benefits and payment</Topic>  <DefaultText>$40</DefaultText> </UserTextQuestion>

More generally, a Variable has an assigned data type, as follows:

<Variable type=“DollarValue” name=“ContractorHourlyRate”query=“ContractorRate”/>

The data types are defined either in the logic file:

<DataTypes xmlns=“http://www.w3.org/2001/XMLSchema”>   <simpleTypename=“DollarValue”>    <annotation>     <documentation>       An amountof money in dollars, as in“$100.50”     </documentation>    </annotation>     <restriction base=“string”>     <patternvalue=“$[0–9]+(\.[0–9]{2})?”/>    </restriction>   <simpleType></DataTypes>or in a separate location for global access:

<?xml version=“1.0” encoding=“utf-8” ?> <schemaxmlns=“http://www.w3.org/2001/XMLSchema”>  <!-- Some example types --> <simpleType name=“NonEmptyString”>   <annotation>    <documentation>Astring containing at least one character</documentation>   </annotation>  <restriction base=“string”>    <minLength value=“1”></minLength>  </restriction>  </simpleType> <simpleType name=“SimpleDate”>  <annotation>    <documentation>A date in the format &quot;15 Jan2002&quot;</documentation>    <appinfo>     <SL:DateFormatxmlns:SL=“http://www.speedlegal.com/namespaces/smarts”>dd MMMyyyy</SL:DateFormat>    </appinfo>   </annotation>   <restrictionbase=“string”></restriction>  </simpleType>  <simpleTypename=“DollarValue”>   <annotation>    <documentation>An amount of moneyin dollars, as in &quot;$100.50&quot;</documentation>   </annotation>  <restriction base=“string”>    <patternvalue=“$[0–9]+(\.[0–9]{2})?”></pattern>   </restriction>  </simpleType>

This data typing relies on XML Schema simple types, as described athttp://www.w3.org/TR/xmlschema-2/.

The documentation element of the simpleType is used to provideexplanatory text to the user during the authoring and interview stages.Document authors are provided with a list of available data types. Oncea Variable is assigned a type, the Query that populates it returnscontent of the required type. If the Query results in an Interview Item,the user inputs data of the required type. If the input data is not ofthe required type, then the user is provided with feedback using thedocumentation element, and is informed as to what data-type is expected.The Interview Item is then re-answered.

During the authoring process, the documentation element can be used toindicate to an author what each data type is intended to represent.

The appinfo element of a simpleType can be used to perform customisedchecking in addition to schema type checking. In the example above,SimpleDate is a custom date format. A value of this type is validated intwo phases. It is first checked to be a string according to the normalschema validation rules, identified as such via the restriction element.Secondly, it is checked using a separate more specific validationfunction identified by the appinfo element.

Interview Item responses are type-checked using schema data typevalidation functions. These are available in libraries such as Sun's XMLData Types Library (xsdlib), available athttp://wwws.sun.com/software/xml/developers/xsdlib2/. These functionscan also be used within the authoring environment to check the type ofdefault values.

In the preferred embodiment, MultipleChoiceQuestion and UserTextQuestionare distinct elements, even though their content shares some commoncharacteristics (e.g., a question). In an alternative embodiment, thecommon characteristics are abstracted out in the DTD, (or,alternatively, schema) as follows:

-   -   <!ELEMENT InterviewItem (question, Topic, Notes?,        (MultipleChoiceQuestion|UserTextQuestion))>

Indeed, the InterviewItems package 408 of the Processing Engine 202 ofthe preferred embodiment uses an abstract class called InterviewItemthat captures the commonalities between MultipleChoiceQuestion,UserTextQuestion, etc, with subclasses that represent the specifics ofeach case.

Moreover, although UserTextQuestion is implemented with a type attributein the preferred embodiment, the different types could alternatively beimplemented as elements in their own right, in which case theInterviewItem element declaration might look like:

-   -   <!ELEMENT InterviewItem (question, Topic, Notes?,        (MultipleChoiceQuestion|UserTextQuestion|Duration|Time|Date|Decimal|Integer))>

A party reference processing instruction is used by the processingengine 202 to generate text referring to a party. For example, thefollowing:

<?SpeedLegal  <PartyReference IDREF=“Employee”LogicSource=“LogicSource_1”  Style=“Pronoun” Type=“PartyDetail_1”> ?>in a source XML document results in the insertion, into the instancedocument, of the value of the PartyDetail whose ID corresponds to theType attribute for that party. In this example, the relevant party is“Employee”.

<Party Assessable=“true” ID=“Employee”> <DisplayName>Employee</DisplayName>  <Role>The person to be offered aposition under this letter.</Role>  <PartyDetails>   <PartyDetailID=“PartyDetail_0” Name=“Firstname”>    <Value Gender=“Unspecified”Number=“Unspecified”>     <InsertUserText IDREF=“EmployeeFirstname”/>   </Value>   </PartyDetail>   <PartyDetail ID=“PartyDetail_1”Name=“Pronoun”>    <Value Gender=“Unspecified”Number=“Singular”>He</Value>    <Value Gender=“Female”Number=“Singular”>She</Value>    <Value Gender=“Unspecified”Number=“Plural”>They</Value>   </PartyDetail>  </PartyDetails> </Party>

It can be seen from this example that the PartyDetail can contain valuesfor different Gender and Number. Assuming the Gender and Number of theparty has been ascertained (in this embodiment a question to do so isautomatically generated by the processing engine 202 when required), thecorresponding value can be evaluated by the Processing Engine 202, andinserted by the Rendering Engine 204, as described below.

It will be evident that other attributes could be included on thePartyDetail Value children, for example, “Formal”, which would be usefulwith some languages other than English.

The example document contains a processing instruction specifying anArrayRowIterator:

<tr>  <?SpeedLegal <ArrayRowIterator repeat=“NumberOfLeaveTypes”/>?>  <td><?SpeedLegal <ArrayReference IDREF=“LeaveType”/>?>

If an XML element has an ArrayRowIterator child, then that element (<tr>in this example) will be copied into the instance document one or moretimes. When the source document is processed by the Processing Engine202, the processing engine 202 determines how many times that element isto be included in the instance document. To determine this, it uses a“repeat” attribute. If the value of the repeat attribute is a positiveinteger, then the element is included that many times. Otherwise, thevalue of the repeat attribute is the name of an interview item that canonly take an integer response (preferably, any limit on the range isspecified in that interview item).

For each time it is copied in, a distinct value is required for eachInterview Item referred to in an ArrayReference processing instruction.For example, if the value of the repeat attribute was 2, then the firsttime the <tr> element appeared (e.g., the first row), theUserTextQuestion “LeaveType” might have value “Annual Leave”; and thesecond time (e.g., the second row), “Maternity Leave”.

The InterviewItems package 408 contains a class that represents anArrayRowIterator. The ArrayRowIterator class contains a collectionsobject which contains UserTextQuestions and MultipleChoiceQuestions foreach row. When the ArrayRowIterator is passed to the invoking process412 to be answered, the UserTextQuestions and MultipleChoiceQuestionscontained within it are asked as necessary.

In the preferred embodiment, there is no corresponding element in anylogic source for an ArrayRowIterator processing instruction. In otherwords, nothing is needed in any of the logic sources (beyond ordinaryInterview Items e.g., MultipleChoiceQuestions and UserTextQuestions)which are referenced by the ArrayReference processing instructions).

It is often desirable to use an Interview Item, within an element thathas an ArrayRowIterator child, that takes the same value each time theelement is repeated (in other words, such an Interview Item does not getasked for each row).

Consequently, the preferred embodiment uses the same value each timeunless an ArrayReference processing instruction is provided. TheArrayReference processing instruction specifies that the correspondingitem is to be treated as an array of questions (e.g., asked again foreach row), rather than assuming this for any interview item that occurswithin an element with an ArrayRowIterator child. If that assumptionwere valid, then there would not be any need for an ArrayReferenceprocessing instruction.

An alternative embodiment which did not make this assumption but alsodid not use an ArrayReference processing instruction might include anattribute on each Interview Item which indicated whether in an array theinterview item was asked just once, or once each array iteration. Forexample, that attribute might be named ArrayRowIteratorBehavior withallowed values “variant” or “invariant”, and appear on the Questionchild of a UserTextQuestion or MultipleChoiceQuestion.

A SmartModule processing instruction is used in a source document toindicate that a fragment of XML at a specified URI is to be retrievedwhen the source document is run through the processing engine 202. Forexample, the following is taken from the example source document:

<?SpeedLegal  <SmartModule uri=“/home/jml/termination.sm”>  <PartyMapping>    <PartyMap From=“Contractor” To=“Employee”>    <PartyDetailMap From=“Shortname” To=“Firstname”/>    <PartyDetailMap From=“Fullname” To=“Firstname”/>    </PartyMap>  </PartyMapping>  </SmartModule> ?>

The PartyMapping is used to translate PartyReferences in the XMLfragment referenced by the SmartModule PI to references to party detailson parties that are known to the source XML document. For example,consider a base or main XML document 812 that refers to parties P1, P2,and E, as shown in FIG. 9. The XML document 812 references the firstlogic source 802 which contains references to parties P1 and P2. The XMLdocument 812 also references a second logic source 804 that containsreferences to parties A and B only. The base document 812 alsoreferences a third logic source 806 that contains references to partiesC, D, and E only. However, the third logic source 806 itself refers to afourth logic source 808, containing references to parties M and N. Thethird logic source 806 (which defines parties C, D and E) needs to uselogic contained in the fourth logic source 808. However, the only partynames “known” to the fourth logic source 808 are M and N. To allow thelogic referring to parties M and N in the fourth logic source 808 to beused for parties C and D, the reference to the fourth logic source 808in the third logic source 806 includes party mapping instructions to mapany references to party M in logic imported from the fourth logic source808 to refer instead to party C. Similarly, party N is mapped to partyD. By performing this party mapping, the third logic source 806 is ableto use the logic contained in the fourth logic source 808 in statementsreferring to parties known only to the third logic source 806.

Referencing and party mapping can be nested. In order for the main XMLdocument 812 to make use of the logic contained in the second logicsource 804 and the third logic source 806, the main document 812includes party mapping instructions to map parties A and B of the secondlogic source 804 to parties P1 and P2, respectively. For the third logicsource 806, parties C and D are mapped to parties P1 and P2,respectively; because there is no mapping for party E, it becomes“known” to the main XML document). However, because the third logicsource 806 contains a reference to the fourth logic source 808, thelogic imported from the fourth logic source 808 effectively undergoestwo levels of party mapping, referred to as a party mapping chain. Thatis, references to parties M and N in logic from the fourth logic source808 that were already mapped to C and D as described above are nowmapped again, in this case to parties P1 and P2, respectively, whenimported into the main XML document 812.

If a single logic source is used more than once (e.g., it is used indifferent logic sources, in which case, in the example in FIG. 8, thatlogic source would be depicted more than once), then instances of apiece of logic contained within it that is used more than once areregarded as distinct if and only if the party mapping chains for theinstances of the logic sources are distinct.

As shown in FIG. 10, party mapping can also be performed for XML sourcefragments imported into the main XML source document 812 via aSmartModule processing instruction. For example, a first XML fragment1002 contains references to parties X and Y. In order to import thisfragment 1002 into the main XML document 812, these parties are mappedto parties known to the main XML document 812, i.e., two of the partiesP1, P2, and E. Similarly, a second fragment 1004 containing referencesto a party Z can be imported into the main XML document 812 by mappingthe party Z to one of these three parties.

A Notes processing instruction is used to present one or more notes to auser, via their browser display and/or in a printed document. Forexample:

<?SpeedLegal  <Notes>   <Note CompletionInstruction=“false”ShowExternalUsers=“false”     UserLevel=“Non-Specialist”>   <NoteTitle>Paid and Unpaid Leave</NoteTitle>    <NoteBody><p>Allemployees can request <b>unpaid</b>     leave</p><p>Only<b>Full-time</b> or <b>Part-time</b>     employees who have accruedleave can request <b>paid</b>     leave.</p></NoteBody>   </Note> </Notes> ?>

The CompletionInstruction attribute indicates whether the note providesinformation as to how the document should be completed; theShowExternalUsers and UserLevel attributes allow the note to be shown ornot shown, depending on whether the user matches the specified criteria.UserLevels can be defined arbitrarily. A user is defined to be externalfor the purposes of ShowExternalUsers if, in a role-based access controlsystem, the user is in an external role (i.e., external to theorganisation running the document assembly system). Notes can also beattached to a question or a response of a UserTextQuestion or aMultipleChoiceQuestion in a logic source.

The MetaInformation processing instruction allows meta-information to beattached to an element in a source document. There is also aMetaInformation element defined in the grammar for a Logic Source. Inthis embodiment, that definition uses concepts provided by RDF andDublin Core, as described at http://www.w3.org/TR/REC-rdf-syntax andhttp://dublincore.org/schemas/xmls/, respectively. The format of theMetaInformation PI data is the same as the definition of theMetaInformation element in the Logic Source grammar.

Most of the examples presented above demonstrate the resolution ofMutipleChoiceQuestions and UserTextQuestions by presenting a question toan end user and receiving a response to that question from the end user.In an alternative embodiment, where UserTextQuestions, ReusablePhrases,Conditions and ArrayRowIterators (Repeats) are viewed as specificinstances of a general class of constructs named Variables, a LogicFilecan be constructed such that Variables are able to be resolved fromother sources (Queries).

Consider the following LogicFile elements:

<LogicSetup>   <DataTypes xmlns=“http://www.w3.org/2001/XMLSchema”>   <simpleType name=“DollarValue”>     <annotation>      <documentation>         An amount of money in dollars, as in“$100.50”       </documentation>      </annotation>      <restrictionbase=“string”>       <pattern value=“$[0–9]+(\.[0–9]{2})?”/>    </restriction>    <simpleType>    <simpleType name=“SimpleDate”>    <annotation>      <documentation>A date in the format &quot;15 Jan2002&quot;</documentation>     <appinfo>      <SL:DateFormatxmlns:SL=“http://www.speedlegal.com/namespaces/smarts”> dd MMM yyyy     </SL:DateFormat>     </appinfo>     </annotation>     <restrictionbase=“string”></restriction>    </simpleType>   </DataTypes>  <DataSources>    <DataSource type=“jdbc” name=“database1”>     <Paramname=“driver” value=“com.microsoft.mssql.Driver”/>     <Param name=“url”value=“jdbc://127.0.0.1”/>     <Param name=“username” value=“GenericUsername”/>     <Param name=“password” value=“Generic Password”/>   </DataSource>   </DataSources>   <Variables>    <Variabletype=“SimpleDate” name=“StartDate”    query=“GetStartDate”/>   <Condition name=“MaternityLeave” query=“IsFemale”/>    <Repeatname=“NumberJobs” query=“NumberJobOpenings”/>    <Variable type=“number”name=“CalculatedNumber”    query=“js−1” />    <Variabletype=“DollarValue” name=“ContractorHourlyRate” query=“ContractorRate”/>  </Variables>   <Queries>    <Query name=“GetStartDate”>     <Answers>     <Answer ref=“StartDate”/>     </Answers>     <UserTextQuestioncolumns=“40” rows=“1”>      <Question>Please enter <PartyReferenceparty=“Employee” style=“Shortname” ref=“N232”/>'s startingdate</Question>      <DefaultText>01 Jan 2003</DefaultText>    </UserTextQuestion>    </Query>    <Query name=“IsFemale”>    <Answers>      <Answer ref=“MaternityLeave”/>     </Answers>    <Condition>      <Test var=“EmployeeGender” equals=“female”/>    </Condition>    </Query>    <Query name=“ContractorRate”>    <Answers>      <Answer ref=“ContractorHourlyRate”/>     </Answers>    <Constant value=“$25.00”/>    </Query>    <Query name=“js−1”>    <Answers>      <Answer ref=“CalculatedNumber”/>     </Answers>    <Script language=“javascript”>      <Parameters>       <Parameterref=“reference-to-some-parameter”       name=“foo”/>       <Parameterref=“reference-to-another-param”       name=“bar”/>      </Parameters>     <Function>        (foo + bar) / 10 * Math.cos(foo+1)     </Function>     </Script>    </Query>    <Query source=“database1”name=“NumberJobOpenings”>     <Answers>      <Answer ref=“NumberJobs”/>    </Answers>     <DatabaseQuery>      <Parameter name=“arg1”ref=“Department”/>      <Result column=“1” ref=“NumberJobs”/>     <Query>       select count(positions) from positions wheredepartment=${arg1} and filled=false;      </Query>     </DatabaseQuery>   </Query>   </Queries>  </LogicSetup>

In the fragment above, five Variables or differing types are defined andtheir values are obtained from various sources, as listed in the Tablebelow.

Variable Name Type Source StartDate SimpleDate Uses UserTextQuestionInterview Item to obtain value MaternityLeave Condition (boolean) Testanswer to a MultipleChoiceQuestion Interview Item to determine genderNumberJobs Repeat Uses a database query (nonNegativeInteger) todetermine the number of unfilled positions in a given departmentCalculatedNumber number Calculates a result based on a function andother Variables defined in the Logic File ContractorHourlyRateDollarValue Constant value

In this embodiment, a UserTextQuestion is an Interview Item Query thatis used to populate a Variable of any data type. A Condition is aVariable of fixed type (boolean) that obtains a true or false value froma Query. Repeats or ArrayRowIterators are Variables of fixed type(integer zero or greater—nonNegativeInteger) where the value is obtainedfrom a Query. A Variable is a general element of any type that obtainsits value from a defined Query. ReusablePhrases are collections ofarbitrary Conditional text, PartyReference and InsertUserText elementsdefined within the logic file that allow users to conveniently definereusable objects. A Query is an element that populates one or moreVariables (Answers) by taking in zero or more Parameters (otherVariables). Queries encompass:

-   -   (i) InterviewItems where the Query is resolved via the interview        e.g. MultipleChoiceQuestions, UserTextQuestions;    -   (ii) evaluations where the Query is resolved by the result of        some function expressed using set syntactic rules. The        evaluation syntax allows different languages to be used to        evaluate the expression. In the example above JavaScript is        used. Parameters may be passed into the function and these can        be given local aliases such that language specific variable name        constraints are not violated; and    -   (iii) other queries such as database lookups, extraction of        information from other files, retrieval from web services,        directory services etc. In the example above a database lookup        is demonstrated where the database setup parameters are defined        within the <DataSources> element. Alternatively these parameters        could be defined in a separate location for global access.

A Query contains references to the Variables or Answers that itpopulates. A single Query can potentially resolve many Variables. Thisis especially useful for database sources where one lookup can returnmany fields of data. A Variable may also reference its resolving Queryfor convenience. A Query implementation may contain a default value thatis used when the Query fails. Queries may fail for a variety of reasonsincluding inaccessibility, recursive or looping queries, incorrectsyntax, and incorrect setup.

Failure mechanisms can be defined such as:

-   -   (i) document is not generated and feedback is presented to the        user;    -   (ii) document is generated with default text if it exists or        markers such as ## if it does not; and    -   (iii) the user is prompted to provide the information that the        Query could not resolve.

It should be noted that the LogicFile structure depicted above decouplesthe declaration of the Variable from information about where and how itis resolved.

Variables can be referenced within an XML document as follows:

<?xml version=“1.0” encoding=“UTF-8”?> <!DOCTYPE Letter PUBLIC“-//SpeedLegal//Letter 1v0//EN”“file:///home/speedlegal/dtd/xhtml-letter/dtd/xhtml-letter-v2.dtd”><Letter>  <?SpeedLegal   <LogicSources>    <LogicSourceID=“LogicSource_1” uri=“/files/logic/LS1WD.lgc”version=“/history/SmartRepository/9/1.2”/>    <LogicSourceID=“LogicSource_2” uri=“/files/logic/LS2WD.lgcversion=“/history/SmartRepository/19/1.6”>     <PartyMapping>     <PartyMap From=“Contractor” To=“Employee”>       <PartyDetailMapFrom=“Shortname” To=“Firstname”/>       <PartyDetailMap From=“Fullname”To=“Firstname”/>      </PartyMap>     </PartyMapping>    </LogicSource>  </LogicSources>  ?>  <?SpeedLegal   <MetaInformation>    <rdf:RDFxmlns:dc=“http://purl.org/dc/elements/1.1/”xmlns:rdf=“http://www.w3.org/TR/WD-rdf-syntax-ns#”>    <rdf:Description>      <Metadata>       <dc:Type Genesis=“Original”Status=“Unapproved” Use=“Precedent”/>       <dc:Title>Lettertemplate</dc:Title>       <dc:Description>Template businessletter</dc:Description>      <dc:Subject><Keyword>Letter</Keyword></dc:Subject>      <dc:Creator>        <Name>SpeedLegal</Name>       <Organisation>SpeedLegal</Organisation>       <md.ContactDetails>         <md.Address>Level 4, 85 Queen Street,Melbourne, Victoria</md.Address>         <md.Phone>+61 3 96700141</md.Phone>         <md.Email>info@speedlegal.com</md.Email>        <md.Fax>+61 3 9670 0142</md.Fax>        </md.ContactDetails>      </dc:Creator>       <RevisionHistory> <Revision><dc:Contributer><Name>SpeedLegal</Name><Organisation>SpeedLegal</Organisation><md.ContactDetails><md.Address>Level 4, 85 Queen Street,Melbourne, Victoria</md.Address><md.Phone>+61 3 96700141</md.Phone><md.Email>info@speedlegal.com</md.Email><md.Fax>+61 39670 0142</md.Fax></md.ContactDetails></dc:Contributor><dc:Date>6/2/200213:49</dc:Date><What ChangeType=“BrandNew”>Lettercreation</What></Revision>       </RevisionHistory>      </Metadata>    </rdf:Description>    </rdf:RDF>   </MetaInformation>  ?> <LetterHead>   </Date>   <Salutation/>  </LetterHead>  <LetterBody>  <p>    <?SpeedLegal <PartyReference IDREF=“Employee”LogicSource=“LogicSource_1” Style=“Firstname” Type=“PartyDetail_0”/> ?>shall commence work on <?SpeedLegal <InsertUserText IDREF=“StartDate”LogicSource=“LogicSource_1” /> ?>.   <p>    <?SpeedLegal     <ConditionIDREF=“PaidLeave” LogicSource=“LogicSource_1”/>    ?>    <?SpeedLegal    <PartyReference IDREF=“Employee” LogicSource=“LogicSource_1”Style=“Pronoun” Type=“PartyDetail_1”/>    ?> shall be eligible for paidleave.</p>   <p>    <?SpeedLegal     <Notes>      <NoteCompletionInstruction=“false” ShowExternalUsers=“false”UserLevel=“Non-Specialist”>       <NoteTitle>Paid and UnpaidLeave</NoteTitle>       <NoteBody><p>All employees can request<b>unpaid</b> leave</p><p>Only <b>Full-time</b> or <b>Part-time</b>employees who have accrued leave can request <b>paid</b>leave.</p></NoteBody>      </Note>     </Notes>    ?>    <?SpeedLegal    <PartyReference IDREF=“Employee” LogicSource=“LogicSource_1”Style=“Firstname” Type=“PartyDetail_0”/>    ?> may request <?SpeedLegal<InsertReusablePhrase IDREF=“PaidOrUnpaidLeave”LogicSource=“LogicSource_1”/>?> by filling in a request form at leastone month prior to the earliest date required.</p>   <p>    <?SpeedLegal<Condition IDREF=“AmountOfLeave.negotiate”LogicSource=“LogicSource_1”/>?>The amount of leave is negotiated withthe employee.</p>   <p>    <?SpeedLegal <ConditionIDREF=“AmountOfLeave.award” LogicSource=“LogicSource_1”/>?>The amount ofleave is determined according to the relevant award.</p>   <p>Theemployee has the following leave entitlements: <object>     <table>     <tbody>       <tr>         <?SpeedLegal <RepeatID=“NumberOfLeaveTypes”/>?>        <td><?SpeedLegal <InsertUserTextIDREF=“LeaveType”/>?> </td>        <td><?SpeedLegal <InsertUserTextIDREF=“LeaveAmount”/>?> </td>       </tr>      </tbody>     </table>   </object>   </p>   <?SpeedLegal    <SmartModuleuri=“/home/jml/termination.sm”version=“/history/SmartRepository/10/1.5”>     <PartyMapping>     <PartyMap From=“Contractor” To=“Employee”>       <PartyDetailMapFrom=“Shortname” To=“Firstname”/>       <PartyDetailMap From=“Fullname”To=“Fullname”/>      </PartyMap>     </PartyMapping>    </SmartModule>  ?>  </LetterBody>  <LetterTail>   <Closing/>   <Sender/> </LetterTail> </Letter>

The StartDate variable, which is defined in the LogicFile example aboveas a SimpleDate, is inserted into the document via an InsertUserTextprocessing instruction.

The XML document example above also demonstrates how versioning isimplemented in this alternative embodiment. There is a “version”attribute on the LogicSource element indicating that this documentrequires a particular version of the logic resource identified by the“uri” attribute. This method for identifying resources and versions ofresources is consistent with the DeltaV standard for version control, asdescribed at http://www.webdav.org/deltav/. The “version” attribute isalso present on the SmartModule.

Versioning offers a number of advantages to the system, including theability to incrementally change, rollback and record differences betweenversions of a document. When a new version is created, the author isprompted to supply information relating to the changes made. If a morerecent version of a LogicSource or a Module is available, a user canupdate to the newer version of the resource (if compatible).Compatibility is determined by checking that all references in thedocument to the old version will be resolved by the new version. Thiscreates the possibility for LogicSources and Modules to be maintainedindependently of documents that refer to them. Versioning avoids thepossibility of logical inconsistencies. These can occur where a sharedLogicSource is modified such that not all Variables can be resolved.Since a given document can only ever point to a particular version of aLogicSource or Module, this is never possible. Finally, versioningcreates the option for ‘publishing’ a particular version of a documentto users while the document continues to be developed. Some users may berestricted to only being able to access these ‘published’ or approveddocuments.

A standard XML editor designed purely for editing XML documents onlyneeds to concern itself with the document grammar, the user interface,and the XML document. In contrast, the editor 112 of the documentassembly system performs standard editing functions but also:

-   -   (i) defines and manipulates logic in logic sources 210 according        to the logic grammar 214;    -   (ii) refers to and manipulates references to logic sources 210        within XML source documents 208. This involves recognising the        Processing Instructions described above and handling them as if        their PI data were ‘real’ XML elements in the XML source        document 208. It also includes ensuring that all of the logical        interactions between a logic source 210 and the XML source        Document 208 are ‘valid’. To do this, the editor 112 treats the        source document 208 and the logic sources as if they were a        single document, so that, for example, the IDREF in a Condition        Processing Instruction to a Condition ID in a logic source can        be validated; and    -   (iii) presents a user interface to the user that allows an XML        source document, logic source and logic references within an XML        source document to be easily manipulated.

As shown in FIG. 12, the process of generating input files with theeditor 112 of the document assembly system typically includes XML sourcedocument (without logic) creation and editing at step 1202, logic sourcecontent creation and editing at step 1204, and then creation and editingof logic references within the XML source document at step 1206.

FIG. 13 is a screenshot of a window display generated by the editor 112during editing of a source XML document representing a letter. Thewindow display includes a pull-down menu toolbar 1302, an icon toolbar1304, and a document window 1306. The document window 1306 is verticallydivided into a structure portion 1308 on the left and a detail portion1310 on the right. The structure portion 1308 is itself verticallydivided, with a hierarchical display 1312 of the XML elements of thedocument on the left, and an abbreviated description display 1314 ofeach element on the right. The detail display 1310 includes text boxes1316 to 1322 for displaying and entering XML elements and textualcontent. Pull down menu buttons 1324 to the left of each text box 1316to 1322 allow the insertion of XML elements and processing instructions.To insert elements or processing instructions within a body of text, theuser can bring up a menu of allowable insertions by either using themouse (right-licking) or a key combination. This will insert the elementor processing instruction within the text at the current position of thecursor. The presence of a condition processing instruction associatedwith the content of a text box is indicated by the presence of a red doton the corresponding pull down menu icon 1324. An orange dot on the icon1324 denotes a Note. Thus in FIG. 13 the first text box 1316, third textbox 1318, and the fourth text box 1320 represent conditional textelements that may or may not be included in an instance documentgenerated from this source document being edited depending upon thevalue of the condition associated with each text element. The secondtext box 1322 has a note that does not form part of the text of theinstance document but is viewable in HTML and PDF renderings of theinstant document, as a pop-up window, for example.

FIG. 14 is a screenshot of the editor 112 window display afterdefinition of a multiple choice question. The variable associated withthis question is named Employment_type, and three conditions,Employment_type.Casual, Employment_type.PartTime, andEmployment_type.FullTime indicate whether an employee is employed on acasual, part-time, or full-time basis. A second multiple choicequestion, AmountOfLeave, is also shown, with associated conditionsAmountOfLeave.negotiate and AmountOfLeave.award. These conditions can beused to select the appropriate text for inclusion in an instancedocument depending upon the values of these variables, which aredetermined by responses received from a user or some other data source,as described above.

FIG. 15 shows a screenshot of the editor 112 window display duringdefinition of the question associated with the AmountOfLeave variabledescribed above. An ID text box 1502 allows the user to enter the IDname of the question, and a question text box 1504 is provided for theuser to enter the actual text of the question that will be presented tothe user. Note that, in this case, a party reference is included in thequestion text so that the employee's first name can be included in thistext when it is displayed to an end-user. A pull down menu 1506 allowsthe user to specify whether the default answer to this question shouldbe determined on the basis of a bias favouring a particular party, forexample, employee or employer, or a predetermined default value. In thiscase, a bias has been selected, and consequently a bias button 1508 isdisplayed for each possible response to the question. A bias button 1508is used to specify the degree to which the corresponding answer suits aparticular party. If, during an interview round, an end-user specifiesthat the selected party is to be favoured, then the default answer tothat question will be the one which best suits the selected party. Thisinformation, including bias and/or fixed default information, isincluded in the SelectionCriteria element associated with each response.

A prompt text box 1510 is provided for editing each possible response(as it will be presented to the user) to this multiple choice question.Value text boxes 1512 allow the user to enter a variable valueassociated with each response. For example, if the award entitlementsresponse was selected by a user, the MultipleChoiceQuestion or variableAmountOfLeave would have value “award”, and the related conditionsAmountOfLeave.award and AmountOfLeave.negotiate would have a values oftrue and false respectively. “Add notes” buttons 1514 are provided foreach response, allowing the user to add note text which can be displayedduring the corresponding interview to assist a user to select theappropriate response.

Within the editor 112, the user may also need to be able to reuse achunk of XML with its associated logic. A reusable chunk of XML isreferred to as a Module.

A Module comprises:

-   -   (i) the XML element or text the user has selected;    -   (ii) external-items (that is, items in the document but outside        the text selected by the user that are referred to (generally by        ID) by that text or by a reference from that reference and so        on); and    -   (iii) a LogicSources element declaring logic required by (i) and        (ii).

To make a Module available for re-use, the editor 112:

-   -   (i) exports the element or text the user has selected;    -   (ii) identifies and possibly exports external-items, such that        the entire module is able to be made valid once it has been        imported into a target document; and    -   (iii) identifies all logic that the module references and        ensures that that logic is in the logic sources declared in the        Module's LogicSources element.

There are two ways that a user may desire the module to be used. In thefirst, a copy of the module is imported into the document—this allowsthe author to modify the text and/or logic as the module now forms partof the target document. For a module copy, the editor 112:

-   -   (i) imports the text—ensuring that it is valid in the target        document. This may mean altering identifiers to allow the import        to occur;    -   (ii) imports or ensures that any external-items specified in the        module are present in the target document. This may mean        altering identifiers to allow the import to occur;    -   (iii) ensures the presence of (importing into a logic source        used by the target document if necessary), all associated logic        referred to by the text, external-items or from within the logic        itself. This may mean altering identifiers to allow the import        to occur; and    -   (iv) maps any Party references (if possible) in the text, logic        and external-items to those used in the target document.

Alternatively, the user can import into the document a link to themodule—this can point to a current version of the module, and anymodifications subsequently made to the module are automaticallyreflected in the resulting document. For a module link, the editor 112:

-   -   (i) creates a SmartModule processing instruction in the target        document (which links the module to the target        document)—ensuring that it would be valid if present in the        target document. This can include providing a map of identifiers        that need to change in order to allow the import to occur;    -   (ii) displays the module to the user so that the text can be        viewed (but not edited) as if it were part of the target        document;    -   (iii) ensures that any external-items required by the module are        present in the target document (adding them if necessary);    -   (iv) adds logic sources required by the module to the target        document LogicSources;    -   (v) provides party mapping (if possible) so that the module can        be imported into the target document;    -   (vi) provides a means by which identifiers (declarations and        references) in the module can be kept track of such that the        target document cannot be invalidated when the module is        imported into the target document by the Processing Engine 202.        The editor 112 tracks all identifiers used in the XML document        including linked Modules without having to import or fetch the        Module every time. This is achieved by:        -   (a) keeping references to logic made from the linked Module;        -   (b) keeping references to links between Module elements and            elements defined in the XML document; and        -   (c) keeping references to declarations made within the            linked Module.

In some circumstances, it may be desirable to ensure that an instanceXML document can be generated which conforms to the same grammar as thesource document, for example, if the XML instance document is to be usedoutside the document assembly system (for example, edited in a standardXML editor).

If it is possible to place conditions on any element in the source XMLdocument, then there is no guarantee that the instance XML document willbe valid.

As an example, suppose the DTD (xhtml-letter-v2) used for the letterdocument above specified that a <letter> must have one and only one<LetterHead> child. Then, if a user were able to place a condition onthe LetterHead, and in processing the source document through theProcessing Module 202 that condition evaluated to false, the<LetterHead> child would be omitted from the instance XML document, withthe result that the instance XML document would be invalid.

XML grammars can express a variety of restrictions on the number ofoccurrences that are allowed for particular elements, for example zeroor one, exactly once, and one or more times. If an instance documentdoes not match a specified rule, it will be invalid.

To ensure that the instance XML document is valid, a condition PI canonly be attached to an element if:

-   -   (i) the element is allowed zero or more times; or    -   (ii) the element is allowed to occur zero or once; or    -   (iii) the element is allowed to occur one or more times, and        either: (a) one of the occurrences of the element does not have        a condition attached, or (b) one of the conditions is always        true when the others are false.

In order to express more than one alternative for an element that isonly allowed to occur zero or one times, one condition is applied to theelement itself to determine whether the element appears at all in theinstance XML document, and alternative condition PIs are applied tonodes inside the element (the same rules apply to the use of conditionson these nodes). If an element is to occur exactly once, and it isdesired to allow several possibilities for its textual content, thenconditional phrases are used inside the element—the editor 112 preventsa condition from being attached to the element itself.

Similarly, if an XML document contains an element with an ID, andanother with an IDREF which points to it, then, if the element with theID had a condition on it which evaluated to false, with the result thatthat element was not included in the instance XML document, and theelement with the IDREF was included, the document would be invalid.

Accordingly, if the instance XML document is to be valid, then anyelement with an attribute of type IDREF is subject to conditions thatinclude all the conditions to which the element with the correspondingID is subject. Whenever the conditions to which an element with an ID issubject are altered, the editor 112 ensures that all elements with anIDREF pointing to it are subject to appropriate conditions.

After a source document 208 and its one or more logic sources 210 havebeen defined with the editor 112, they can be used by the processingengine 202 to generate one or more instance documents. The processingengine 202 begins processing an input XML document 208 when the Javacontroller servlet 218 creates an instance of the evaluator 402 inresponse to a request from the user's web browser. In the preferredembodiment, the constructor for the evaluator 402 takes the input XMLdocument as a document object model (DOM) object, but it couldalternatively be passed as text, or as a URI from which it can beretrieved.

Later, the Evaluator 402, in conjunction with the evaluable node package404 and the parties package 406, identifies questions that need to beanswered. In order for it to be able to suggest a default answer oranswers for each question which would result in text intended to favourone party to the document over another (or to automatically answer aquestion that is not a KeyQuestion), the Java servlet 218 may specify tothe Evaluator 402 which party to favour, as ascertained at step 504.

The Evaluator 402 constructs two objects it will need later:operativeConditions, and operativeInterviewItems. It also extracts thelogic from each logic source referred to in the document's LogicSourceselement, and from each logic source referred to in the LogicSourceselements in each logic source, and so on (being careful not to get intoan infinite loop). However, in the preferred embodiment, the Evaluator402 does not extract the logic from a logic source imported by an XMLfragment until the SmartModule processing instruction is encounteredlater. When the logic import is performed, the Evaluator 402 determineshow the parties in that logic source are mapped, relative to the mainXML document (the party mapping chain). Each Condition and InterviewItem(e.g., MultipleChoiceQuestion and UserTextQuestion—there are noArrayRowIterators in a logic source) is stored in a hash table keyed bythe URI of its logic file combined with its party mapping chain and itsown ID, so that discrete instances (as explained above) can be stored,and they can be retrieved efficiently.

Finally, the Evaluator 402 extracts Party declarations from these logicsources, creates a Party object to represent the Party declaration, andstores each Party object in the Parties object of the party package 406,keyed by the URI of its logic file combined with the ID of the Party.Each Party object has objects associated with it representing eachPartyDetail, and each PartyDetail has a means of representing each Valuein it. The Value element is stored in an object named PartyDetailValue.

The invoking process (the Java Controller Servlet 218) then callsevaluator.initialisePartiesInUse( ). The purpose of this method isfirstly, to identify any UserTextQuestions in a Party XML object thatwill definitely need to be answered (i.e., irrespective of whether anyconditions in the document evaluate to true or false), and secondly, toidentify the Party XML objects for which the engine will need to know agender and/or number. It is desirable to establish this up front, sothat for an invoking process 412 which interacts with an end-user, thequestions relating to the parties can be put to the user before theother questions. One of the benefits of doing this is that words inthose other questions that identify a party by using a PartyReferencecan be replaced with the value of that PartyReference.

The method evaluator.initialisePartiesInUse( ) performs a breadth-firsttraversal of the DOM object. The breadth-first traversal is implementedrecursively; recursion stops at any node that has a condition attachedto it. Where in the course of performing the breadth-first traversal, aPartyReference PI is encountered, getValue is invoked on the appropriatePartyDetail. That method is as follows:

public String getValue( Evaluator evaluator )    throwsSpeedLegalLogicException {   if (value!=null) {    return value;   }  boolean returnEarly = false;   String number = party.getNumber( );  String gender = party.getGender( );   if ( gender==null ) {    if (needToKnowGender( ) ) {     // Ask the user the gender question   party.askGender(evaluator);     returnEarly = true;    } else {    // If we don't know it and don't need to know it,     // because theonly value provided is for “unspecified”     gender = “Unspecified”;   }   }   if ( number==null ) {    if ( needToKnowNumber( ) ) {     //Ask the user the number question    party.askNumber(evaluator);    returnEarly = true;    } else {     number = “Unspecified”;    }   }  if (returnEarly) { return null;   }   // If we get here, we'reguaranteed some value for both gender and number   // Is there an exactmatch on gender and number?   String key =PartyDetailValue.constructKey( gender, number);   if ( values.get( key)!=null ) {    value = ((PartyDetailValue)values.get( key )).getValue(evaluator );    return value;   }   // Failing that, fall back topartial matches in some circumstances.   //   Match on Gender first, butcould do Number first if we wanted..   // GENDER   // if we wanted toprohibit match on Unspecified number whenever there   // was a value foreither but not both Singular and plural, we'd   // have if!needToKnowNumber( ) here...    key = PartyDetailValue.constructKey(gender, “Unspecified”);    if ( values.get( key )!=null ) {     value =((PartyDetailValue)values.get( key )).getValue( evaluator );     returnvalue;    }   // NUMBER   //if ( !needToKnowGender( ) ) { - see commentson Gender above    key = PartyDetailValue.constructKey( “Unspecified”,number);    if ( values.get( key )!=null ) {     log.debug(“Partialmatch on number.”);     value = ((PartyDetailValue)values.get( key)).getValue( evaluator );     return value;    }   // What about a matchon completely unspecified?   //if ( !needToKnowNumber( ) &&!needToKnowGender( ) ) {     log.debug(“Trying to match unspecifiednumber and gender.”);    key = PartyDetailValue.constructKey(“Unspecified”, “Unspecified”);    if ( values.get( key )!=null ) {    log.debug(“Match on default only..”);     value =((PartyDetailValue)values.get( key )).getValue( evaluator );     returnvalue;    }   // We could get here if the document author didn't provideUnspecified number   // and Unspecified gender, but only, say FemaleSingular,   // and the end user chose say Male Singular,   log.error(“Nomatch, not even on Unspecified.”);   value = “[* No match for party: “ +party.getKey( ) + ” , detail: “ + id      + ”, of gender ‘“ + gender +”’ and number ‘“    + number + ”’. Document author must fix this. *]”;  return value;

Where necessary, by invoking other methods, getValue causesInterviewItems to be created which represent the questions that need tobe answered. The questions are either MultipleChoiceQuestions that seekto establish the Gender (Male, Female or Neuter) or Number (Singular orPlural) of a Party, or UserTextQuestions that prompt for text formingpart of the value of the PartyDetail for the matching Gender and Number(where ‘matching’ is determined by the procedure implemented by thegetValue method).

When the Evaluator 402 has finished doing this, the invoking process 412checks to see whether there are any InterviewItems that need to beresolved. If there are no InterviewItems that need to be resolved,Evaluator.evaluate( ) is invoked. It extracts any InterviewItems fromthe document which need to be resolved at this point. Its function isdescribed in detail below.

If there are still no interview items that need to be resolved, then theinput document is a trivial case, and the instance XML document would beidentical. Otherwise, the invoking process 412 resolves the interviewitems.

The Java controller servlet 218 creates an HTML form for a user tocomplete in their web browser. However, it will be apparent that thecontroller servlet 218 could alternatively seek responses from someother source, for example, a database which it queries using SQL, a webservice, or some application using its API. As described above, a logicsource can specify a preferred method for resolving either all interviewitems, or some particular interview item, together with the detailsrequired in order to do so (e.g., URL, authentication information, queryetc) which the invoking process 412 attempts to honour. The invokingprocess 412 returns a response for each interview item, even if itcouldn't get a response using the preferred method.

Having resolved the interview items, the invoking process 412 callsEvaluator 402's evaluate( ) method, passing it a set of interview itemsthat contain values. evaluate( ) first transfers the answers from theinterview items proffered by the invoking process 412 to any matchinginterview items for which it was awaiting responses. Because there is aflag on each PartyDetail and each Condition object which ensures thatthe Evaluator 402 only attempts to evaluate it once each time theinvoking process 412 calls Evaluator 402's evaluate( ) method(hereinafter called “interview round”), these flags are reset.

As described above, the Evaluator 402 performs a recursive breadth-firsttraversal of the DOM object. During the course of the breadth-firsttraversal, certain nodes will be encountered that require specialhandling. In this embodiment, these nodes are all processinginstructions so that they can be included in an XML document withoutaffecting its validity.

PartyReference processing instructions are treated as described above.It is possible for the Evaluator 402 to encounter a PartyReference to aPartyDetail not previously encountered (because it occurs below anelement to which a condition is attached). As before, getValue isinvoked on the appropriate PartyDetail.

It will be apparent that in embodiments of the present invention, anynode could be given special handling—either by node name, or node type,in either all documents or only documents using a specified XML schemaor DTD, or indeed by position in the document. In the preferredembodiment, the traversal method calls an empty method which can beoverridden in a subclass of Evaluator to implement this special handlingif desired.

When a node that has a condition processing instruction is encountered,the Evaluator 402 attempts to evaluate it. First, it looks to seewhether that condition has been encountered already (if it has, anobject representing it will be stored in the operativeConditionsobject). If the condition has not been encountered already, an objectthat represents it will be constructed and stored in theoperativeConditions object. Then, if the condition is not fullyevaluated, and if the relevant flag indicates that no attempt has beenmade to evaluate the condition in this interview round, the Evaluator402 attempts to evaluate the Condition.

The Condition is evaluated as follows. Each of the elements that canappear in a Condition—the operators And, Or, Not, Test, UseCondition,and the values True and False—implements an interface that defines amethod named evaluate( ) (not to be confused with Evaluator 402 or itsevaluate( ) method), and has a constructor with the same signature.Because of this, in this embodiment, the Condition object can use a Javaprogramming technique known as reflection to construct objectsrepresenting its children, and call their evaluate( ) method. In turn,if a child of an object is And, Or, Not, Test, or UseCondition, theobjects can recursively construct and call evaluate( ) on an objectrepresenting that child, so that ultimately, each of And, Or, and Not,has arguments that are boolean values that can be evaluated to true orfalse using classical boolean logic. Finally, Condition(True) evaluatesto True, and Condition(False) evaluates to False.

If a Test node is encountered, then when its evaluate( ) method isinvoked, the Test object checks to see whether theMultipleChoiceQuestion it refers to has been instantiated as an object(it will have been if some other Test node which refers to the sameMultipleChoiceQuestion has already been processed). If theMultipleChoiceQuestion has not been instantiated, aMultipleChoiceQuestion object representing it is constructed.

If the invoking process 412 has indicated that only Key Questions shouldbe asked, and this question is not a Key question, then the processingengine 202 can evaluate it automatically using the scoring procedurebased around the SelectionRules and SelectionCriteria for thatMultipleChoiceQuestion (in this embodiment, a method in the objectrepresenting the MultipleChoiceQuestion in the interview item package408 does this). Where a new MultipleChoiceQuestion has been constructed,it will be added to operativeInterviewItems. Each InterviewItem (aMultipleChoiceQuestion is a type of InterviewItem) inoperativeInterviewItems has status either “pending” or “known”.

If a MultipleChoiceQuestion has status pending, then the Evaluator 402waits for the invoking process 412 to provide it with a response valuebefore it evaluates the Test that uses it to true or false.InterviewItems with status pending are not returned to the invokingprocess 412 as they are created, but rather, are only returned when thetraversal has been completed. This makes it easy for an invoking process412 that interacts with a user to put several questions to the user atonce, perhaps organised by the value of the MultipleChoiceQuestion'sTopic child.

If the MultipleChoiceQuestion has status known, then Test's Evaluatemethod will return true if the MultipleChoiceQuestion has a responseequal to the value specified in the Test, and false otherwise.

If the condition evaluates to true, then the traversal can descend intothe node to which the condition applies. If it evaluates to false, thatnode will not be included in the instance XML document (To assist therendering engine 204 later on, the evaluate method of the Evaluator 402adds an attribute named “diedInEvaluation” to an element that had acondition which evaluated to false.). If the condition cannot beevaluated to either true or false, the traversal does not in thisinterview round descend into the node to which the condition applies.Instead, any pending interview items (created as described above) willin due course be returned to the invoking process 412 for resolution, sothat, assuming responses are provided, the condition may be evaluated inthe next interview round.

When an InsertReuseablePhrase processing instruction is encountered, theEvaluator 402 retrieves the ReusablePhrase node it refers to from therelevant logic source, and physically replaces the processinginstruction node in the DOM object with that ReusablePhrase node. Itthen puts an IDREF to that logic source on relevant descendants of theReusablePhrase node, and converts any logic elements in thosedescendants from the XML format used in the logic file to the ProcessingInstruction format appropriate to the XML source document. It is thenpossible to traverse the descendants of the ReuseablePhrase node in theusual way, albeit in a context provided by the party mapping chain forthe logic source it came from (so Conditions and InterviewItems can belooked up correctly).

A consequence of this way of processing an InsertReuseablePhraseprocessing instruction is that a single ReusablePhrase node is insertedinto the document and traversed multiple times if there is more than oneInsertReusablePhrase processing instruction that points to it. In analternative embodiment, each ReusablePhrase node could be traversed justonce, and the result inserted into the document at a later step.

When an InsertUserText processing instruction is encountered, theEvaluator 402 determines whether a UserTextQuestion object representingthe UserTextQuestion the processing instruction points to already existsin operativeInterviewItems. If it does not, the Evaluator 402 creates anew UserTextQuestion object, and adds it to operativeInterviewItems withstatus “pending”.

When an ArrayRowIterator element is encountered, the processing engine202 first checks to see whether its “repeat” attribute has a knownpositive integer value. If it does not, then the ArrayRowIterator cannotbe processed any further until the InterviewItem named in that attributehas a value (it is an error if that value is not a positive integer).Once the “repeat” attribute has a known positive integer value, atwo-dimensional array of InterviewItems is created. The first dimensionis the InterviewItems identified in the ArrayReference processinginstruction descendants of the parent of the ArrayRowIterator; thesecond dimension is the number of rows specified by the “repeat”attribute. The ArrayRowIterator object containing that two-dimensionalarray of interview items is added to OperativeInterviewItems, andresolved in the usual way.

A situation can arise whereby two ArrayRowIterator processinginstructions contain ArrayReference processing instructions pointing tothe same interview item. For example, suppose a first ArrayRowIteratorhas a repeat attribute value of n1, and the second n2. In the preferredembodiment, the Interview Items in the abs(n2−n1) rows common to bothArrayRowIterators are then asked only once. However, alternativeembodiments could require independent values for the InterviewItems inthose rows.

When the breadth-first traversal is complete, the evaluate method of theEvaluator 402 returns control to the invoking process 412. The invokingprocess 412 then asks the Evaluator 402 for all operativeInterviewItemsthat have status pending. If there are none, then the document has beenfully evaluated, and an instance document is created by the RenderingEngine 204. If there are operativeInterviewItems with status pending,the invoking process 412 determines a response value for each of thoseinterview items, as described above followingevaluator.initialisePartiesInUse( ).

Having resolved the interview items, the invoking process 412 callsevaluate method of Evaluator 402, passing it a set of interview itemswhich contain values. This cycle repeats, until such time as there areno pending interview items.

When there are no pending interview items, an instance document in XML,PDF, RTF, HTML, or some other format, can be created from the DOMdocument object which the processing engine 202 has been manipulating.

As the rendering engine 204 creates an instance document, elements ofthe source XML document with conditions that evaluated to false (andtherefore had an attribute named “diedInEvaluation”) are omitted, eachInsertUserText processing instructions is replaced by the value of thecorresponding UserTextQuestion, the ReusablePhrases have replaced theInsertReusablePhrase processing instructions, and so on. This is doneusing XSLT with Xalan extension functions, which get the values ofUserTextQuestions and PartyReferences from the evaluator 402. Inalternative embodiments, an extension function could look up the valueof the condition, instead of relying on the presence or absence of thediedInEvaluation attribute. An alternative to using XSLT for most of therendering engine's work would be to programmatically do anotherrecursive traversal.

Of particular interest is the generation of an instance document intoHTML format. The instance document can be rendered in such a way thatany text that appears as a result of one or more conditions evaluatingto true, or as a result of a response to a UserTextQuestion, isgenerated by the rendering engine 204 as a hypertext anchor. When thatanchor is activated, the user interface displays the question andresponse that resulted in the anchor text being included, as describedabove. In the case of text that is subject to one or more conditions, itwould be possible to display the questions associated with eachcondition. However, in the preferred embodiment, only the questionsassociated with the closest ancestor having a condition processinginstruction are displayed.

When the anchor is activated, it is also possible to reset one or moreof the questions associated with the condition (which means thecondition should be re-evaluated, so that the question is asked again),or, in the case of a UserTextQuestion, to ask it again. Where a questionassociated with a condition is reset, any other condition which usedthat MultipleChoiceQuestion is also reset, as is any other conditionwhich used that condition, and so on.

In the user interface available to a user of the document assemblysystem via their web-browser, when a user moves their mouse over therelevant text, JavaScript and the anchor element's HTML on MouseOverevent is used to generate a pop-up window displaying the relevantquestions and responses, as shown in FIG. 7; when a user clicks on theanchor, the Processing Engine 202 is invoked to reset the relevantquestions.

The HTML rendering of the document also typically provides a list of allthe questions that were answered, together with the user's responses. Ifthe user selects a question link, the Processing Engine 202 resets thatquestion as described above.

Many modifications will be apparent to those skilled in the art withoutdeparting from the scope of the present invention as herein describedwith reference to the accompanying drawings.

1. A computer-readable storage medium having instructions storedthereon, which when executed cause a machine to perform a set ofoperations comprising: generating at least one instance document from atleast one XML source document for a document assembly system; anddetermining content at locations of said at least one instance documentbased on document assembly instructions associated with correspondinglocations within said at least one XML source document; wherein: (i)said at least one XML source document was created by associating saiddocument assembly instructions with at least one initial XML document;(ii) said at least one initial XML document is valid with respect to apredetermined DTD or schema that does not include said document assemblyinstructions; (iii) said at least one XML source document is valid withrespect to the same predetermined DTD or schema as said at least oneinitial XML document; and (iv) at least one of said document assemblyinstructions is associated with one or more corresponding portions ofsaid at least one XML source document, and defines one or moreconditions that determine whether the one or more corresponding portionsof said at least one XML source document will be included in said atleast one instance document.
 2. The computer-readable storage medium asclaimed in claim 1, wherein at least one of said document assemblyinstructions includes one or more references to one or more otherdocument assembly instructions.
 3. The computer-readable storage mediumas claimed in claim 1, wherein said at least one XML source documentincludes one or more references to document assembly instructionsexternal to said at least one XML source document.
 4. Thecomputer-readable storage medium as claimed in claim 3, wherein at leastone of said one or more references to document assembly instructionsincludes information that allows one or more of said document assemblyinstructions to be retrieved from a database.
 5. The computer-readablestorage medium as claimed in claim 1, wherein said at least one XMLsource document includes said document assembly instructions.
 6. Thecomputer-readable storage medium as claimed in claim 1, wherein said atleast one XML source document includes XML Processing Instructions thatinclude or reference said document assembly instructions.
 7. Thecomputer-readable storage medium as claimed in claim 1, wherein one ormore of said document assembly instructions determine one or morequeries, conditions, and/or reusable content for use in determining saidcontent of said at least one instance document.
 8. The computer-readablestorage medium as claimed in claim 7, wherein said one or more queries,conditions, and/or reusable content include interview data defining oneor more questions for a user, and constraining responses to saidquestions.
 9. The computer-readable storage medium as claimed in claim8, wherein said XML source document includes an assembly instruction forincluding in said at least one instance document response text providedby said user.
 10. The computer-readable storage medium as claimed inclaim 7, wherein a condition depends upon one or more other conditions.11. The computer-readable storage medium as claimed in claim 10, whereinsaid conditions are related by Boolean operators.
 12. Thecomputer-readable storage medium as claimed in claim 1, wherein said atleast one XML source document includes one or more references to one ormore queries, conditions, and/or reusable content for use in determiningsaid content of said at least one instance document.
 13. Thecomputer-readable storage medium as claimed in claim 12, wherein thereferenced queries, conditions, and/or reusable content are external tosaid at least one XML source document.
 14. The computer-readable storagemedium as claimed in claim 13, wherein at least one of said queries,conditions, and/or reusable content is stored in a database, and atleast one of said one or more references includes information thatallows the at least one of said queries, conditions, and/or reusablecontent to be retrieved from a database.
 15. The computer-readablestorage medium as claimed in claim 13, wherein said at least one XMLsource document includes one or more references to one or more documentsdefining said one or more queries, conditions, and/or reusable content.16. The computer-readable storage medium as claimed in claim 15, whereinsaid one or more references to said one or more documents are in theform of universal resource indicators.
 17. The computer-readable storagemedium as claimed in claim 15, wherein said one or more documents areXML documents.
 18. The computer-readable storage medium as claimed inclaim 17, wherein said one or more XML documents are valid with respectto a DTD or schema.
 19. The computer-readable storage medium as claimedin claim 18, wherein the set of operations comprises editing said one ormore XML documents defining said one or more queries, conditions, and/orreusable content whilst maintaining the validity of said XML documentswith respect to said DTD or schema.
 20. The computer-readable storagemedium as claimed in claim 17, wherein said XML source document includesan assembly instruction for including in said at least one instancedocument text defined in a referenced XML document.
 21. Thecomputer-readable storage medium as claimed in claim 15, wherein saiddocument assembly instructions include party instructions referring toattributes of a party defined in one or more of said documents.
 22. Thecomputer-readable storage medium as claimed in claim 21, wherein saidparty attributes include one or more of gender and number.
 23. Thecomputer-readable storage medium as claimed in claim 21, wherein saiddocument assembly instructions include party mapping data mapping one ormore parties defined in said document assembly instructions torespective parties of said at least one XML source document.
 24. Thecomputer-readable storage medium as claimed in claim 23, wherein areference to an XML document includes party mapping information formapping a first party used in the referenced document to a second partyused in the referring document.
 25. The computer-readable storage mediumas claimed in claim 1, wherein at least one of said one or morecorresponding portions of said at least one XML source document includesone or more XML nodes in said XML source document, and a correspondingcondition determines whether said one or more XML nodes will be includedin said at least one instance document.
 26. The computer-readablestorage medium as claimed in claim 1, wherein said document assemblyinstructions include application data that can be parsed as XML.
 27. Thecomputer-readable storage medium as claimed in claim 1, wherein said XMLsource document includes an assembly instruction for including anelement multiple times in said at least one instance document.
 28. Thecomputer-readable storage medium as claimed in claim 27, wherein contentof said element is correspondingly modified for each of said times. 29.The computer-readable storage medium as claimed in claim 1, wherein saidat least one instance document is an XML document which is valid withrespect to the same predetermined DTD or schema as said at least one XMLsource document.